FFMpegCore icon indicating copy to clipboard operation
FFMpegCore copied to clipboard

Generating gif bug: invalid file index 1 in filtergraph description..

Open depressedliza opened this issue 2 years ago • 1 comments

I had following code for generating image from video file var result = await FFMpeg.GifSnapshotAsync( videoFullPath, gifFullPath, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));

All working good, but when I try generate gif file (attach) from h264 codec I getting error:

Something went wrong: FFMpegCore.Exceptions.FFMpegException: ffmpeg exited with non-zero exit-code (1 - ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers built with Apple clang version 14.0.3 (clang-1403.0.22.14.1) configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/elizabeth/unistory/itbit-ai-verification-back/WebApp/wwwroot/ac53b268-38ed-4b3d-af40-7ce48f782aca.mp4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: isommp41mp42 creation_time : 2023-06-01T10:15:04.000000Z Duration: 00:00:03.67, start: 0.000000, bitrate: 13729 kb/s Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default) Metadata: creation_time : 2023-06-01T10:15:04.000000Z handler_name : Core Media Audio vendor_id : [0][0][0][0] Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709/bt709/iec61966-2-1, progressive), 888x1920, 13532 kb/s, 51.10 fps, 60 tbr, 600 tbn (default) Metadata: creation_time : 2023-06-01T10:15:04.000000Z handler_name : Core Media Video vendor_id : [0][0][0][0] Invalid file index 1 in filtergraph description [1:v] fps=12,scale=w=200:h=200,split [a][b];[a] palettegen=max_colors=32 [p];[b][p] paletteuse=dither=bayer.) at FFMpegCore.FFMpegArgumentProcessor.HandleCompletion(Boolean throwOnError, Int32 exitCode, IReadOnlyList1 errorData) at FFMpegCore.FFMpegArgumentProcessor.ProcessAsynchronously(Boolean throwOnError, FFOptions ffMpegOptions) at FFMpegCore.FFMpeg.GifSnapshotAsync(String input, String output, Nullable1 size, Nullable1 captureTime, Nullable1 duration, Nullable1 streamIndex) `

I try generate gif from video file from command shell via ffmpeg -i IMG_7260.MP4 output.gif - had no error

https://github.com/rosenbjerg/FFMpegCore/assets/44543901/7d859db7-4fe2-459b-aeba-e5adb235fd4c

depressedliza avatar Jun 01 '23 11:06 depressedliza

@depressedliza Hi,I probably found the root of the problems 。 https://github.com/rosenbjerg/FFMpegCore/blob/6df9495e9fc0053c78e19fdd8d9aeb474b182eda/FFMpegCore/FFMpeg/SnapshotArgumentBuilder.cs#L34 The parameter streamIndex should meaning the sum of input source and not the video or audio channel order. as for the function FFMpegCore.FFMpeg.GifSnapshotAsync(String input, String output, Nullable1 size, Nullable1 captureTime, Nullable1 duration, Nullable1 streamIndex) the input is only one video source, so the streamIndex should be 0。 @rosenbjerg

lucentlc avatar Sep 24 '23 02:09 lucentlc