59

I'm developing a system which needs to store videos in the form:

/path/to/video/<md5 of the file>

So I do not have an output extension. I'm using ffmpeg to convert those videos, but it seems that it uses output file extension to determine the output format, so here's my problem.

Due to the fact I don't have an output extension in file names, is there a way to specify the output format directly in the command line without create temporary files or dirty solutions like this ?

nbro
  • 15,395
  • 32
  • 113
  • 196
Simone Margaritelli
  • 4,584
  • 10
  • 45
  • 70
  • Might also want to use -y to allow overwriting the destination file. If you don't specify -y and the file is in use, ffmpeg will sit waiting for user input. This effectively hangs the process, as I recently discovered. :P – Charlie May 14 '14 at 21:10

2 Answers2

97

Use the -f parameter to tell ffmpeg which output-format to use. E.g

ffmpeg -i input.mpg ... -f mp4 output

to create a file named output in mp4 format.

Greg Kennedy
  • 430
  • 4
  • 23
luukes
  • 1,444
  • 10
  • 9
  • 34
    -f is ALSO used as input format specification, depending on position: ffmpeg -f mpg -i input.mpg ... -f mp4 output.mp4 – yetihehe Oct 08 '14 at 12:21
  • 4
    Note that the question was _"what if I don't have an extension?"_ so your answer should say `output` and not `output.mp4` to prove that it works as per OP's question. – Alexis Wilke Jun 02 '21 at 21:55
  • This helped me figure out my issue as well with streaming to YouTube. https://stackoverflow.com/questions/67943834/ffmpeg-stream-windows-7-desktop-to-youtube-give-invalid-argument – TenG Jun 11 '21 at 22:00
1

Same solution with @luukes but please notice that if you're making aac output, the parameter for -f is adts:

ffmpeg -i input.mpg ... -f adts output

to create a file named output in aac format.

Tran Chien
  • 614
  • 4
  • 10