I want to save a bmp file as 1.mp4 using Ffmpeg, how to achieve it?

The question is very simple. I have some source file, lets call it source.png and I want to encode it as bmp, but to save it as a file with extension mp4. Of course, one way to achieve it is to save it as file with bmp extension and then use command line to rename it to mp4. But, that is not what I want. I want it directly to be saved as mp4.

I searched on internet and I found that in order to achieve it, one should specify -f parameter. This is my command line:

ffmpeg -hide_banner -i source.png -f bmp 1.mp4

And, of course, I got an error Requested output format 'bmp' is not a suitable output format.. I continued searching for solution and I found that calling Ffmpeg with parameter -formats displays all supported formats. I did it and I found only one format containing word bmp:

D  bmp_pipe        piped bmp sequence

Then I replaced -f bmp with-f bmp_pipe`, but again I got the same error. So, how to properly do it?

In general, my question is: given extension (for example bmp in this case), how to determine the word which needs to be placed after -f in order to encode like that extension is present?

Maybe I was not clear enough in the question. I'm looking for a way to find the connection between extension (bmp, png, mp4, avi, etc) and the Ffmpeg parameter I need to pass in order to encode to that extension.

Basically, I'm creating a user interface application where:

  1. User enters extension (for example mp4)
  2. User enters output file name (for example C:\1.exe (just a dumb example))
  3. I need to spawn ffmpeg process which will encode input file like output file is in that extension which user specified

I hope it is more clear now.


You'll have to go through the parent muxer for image sequences, image2:

ffmpeg -i in.png -c:v bmp -vframes 1 -f image2 out.mp4

Run ffmpeg -muxers to get a list of available -f values. There's no central list of extensions linked to muxers.

  • Hm.. Does it apply in general? I mean, I'm searching for a way to ask user for extension and then to encode image (or video) to that extension (but output file is always named .mp4) So, can I replace -c:v bmp with any other extension and it will work? – user769083 Sep 7 '17 at 18:51
  • For image formats, this is the method. For video formats, supply -f ext – Gyan Sep 7 '17 at 18:53
  • I updated the question. So, to summarize, for all image extensions, i need to pass -c:v ext -f image2 and for all video formats I need to pass -f ext, right? Are there any exceptions? – user769083 Sep 7 '17 at 18:59
  • 1
    There's no way to do it automatically because ffmpeg isn't designed to behave as if the output extension is a false flag. That's a very atypical and unanticipated use case, especially considering you can just rename the file afterwards. – Gyan Sep 7 '17 at 19:33
  • 1
    If you're streaming it, and the output URI has no extension, then you have to specify -f. Run ffmpeg -muxers to get a list of available -f values. There's no central list of extensions linked to muxers. – Gyan Sep 7 '17 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy