kokolegorille

kokolegorille

Ffmpeg, video to png

Hello everyone,

I am trying to extract thumbnail from video with waffle and ffmpeg.

I do have a transformer like this

  def transform(:thumb, _) do
    {:ffmpeg, fn(input, output) -> "-i #{input} -f png #{output}" end, :png}
  end

but this fail with

Unable to find a suitable output format

And this fail in the console too.

$ ffmpeg -i small.mp4 -f png out_small.png
...
[NULL @ 0x7f8e93801400] Requested output format 'png' is not a suitable output format
out_small.png: Invalid argument

It looks my ffmpeg does not support png creation, as png is not listed in formats.

$ ffmpeg -formats | grep png
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
 DE apng            Animated Portable Network Graphics
 D  png_pipe        piped png sequence

I have success using apng, or gif, but not png, nor jpg.

I guess it is my ffmpeg version which is broken. It’s the latest installed by brew, on Mac osx.

So my question is, do You have png listed in your ffmpeg formats?

Thanks in advance

Marked As Solved

sneako

sneako

I think you just need to provide a few more arguments to your ffmpeg command and that by default, ffmpeg assumes you want to convert the video to another video format.
I am running MacOS and ffmpeg 4.2.2 as well and am able to create a thumbnail with the following command:
ffmpeg -i sample.mp4 -ss 00:00:01.000 -vframes 1 output.png
Note we tell ffmpeg to take 1 frame (with -vframes 1), from a specific point (-ss <timestamp>) in the video.

Also Liked

kokolegorille

kokolegorille

After many tests, I found the solution. The format to specify is now image2 for png.

This works

  def transform(:thumb, _) do
    {:ffmpeg, fn(input, output) -> ["-i", input, "-f", "image2", "-vframes", "1", output] end, :png}
  end

# or this too

  def transform(:thumb, _) do
    {:ffmpeg, fn(input, output) -> "-i #{input} -f image2 -vframes 1 #{output}" end, :png}
  end

It’s possible to pass a list or a string, but -f image2 is the key.

For reference, this is where I found the way to correctly transform a video to a png thumbnail.

https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence

Thank You all for the helps :slight_smile:

hauleth

hauleth

Are you sure that there are no spaces in input and output?

Kurisu

Kurisu

I have ffmpeg version 3.4.6 and it seems I have the same supported formats.

Here is the output of the command ffmpeg -formats | grep png:

ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
 DE apng            Animated Portable Network Graphics
 D  png_pipe        piped png sequence
kokolegorille

kokolegorille

Thanks, so it seems it’s not only Mac :slight_smile:

OvermindDL1

OvermindDL1

It’s not a syntax issue they were speaking of but rather that the list form should be used as it will properly escape arguments where the string form will not.

However, running ffmpeg -ss 01:23:45 -i some-big-video-I-have.mpeg -vframes 1 -q:v 2 output.png works fine here and I have the same output from ffmpeg -formats | grep png as you do.

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New

We're in Beta

About us Mission Statement