Using ffmpeg to get video info - why do I need to specify an output file?

76,674

Solution 1

It's giving an error because FFmpeg requires that an output file be specified. Using it just to get information about a file isn't its intended use.

Option 1: Ignore the error. FFmpeg prints the file information first, so you can simply get the information you need and ignore the error.

Option 2: Use ffprobe instead. FFprobe is another tool usually packaged with FFmpeg that's designed for getting information about media files. It can even output the information in a variety of easily parsed formats so you don't have to mess around parsing FFmpeg's output.

Solution 2

Very late, but hopefully it can help someone if he doesn't want to use ffprobe (see @blahdiblah answer).

You can use Null with ffmpeg as stated in the documentation:

ffmpeg -i C:\Test\3FA8D0E6-BD61-D160-98BB41304D63FAE3.mp4 -f null -

Solution 3

I ended up using ffprobe instead. Here's my ColdFusion test code... keep in mind that this could be written better. At this point, I'm only interested in width/height/duration.

<cfset fsVideoFile = "C:\videos\test.mp4">
<cfset width = 270>
<cfset height = 480>
<cfset duration = 0>

<cfexecute
   name="ffmpeg\bin\ffprobe.exe"
   arguments="#fsVideoFile# -v quiet -print_format json -show_format -show_streams"
   timeout="60"
   variable="jsonInfo"
   errorVariable="errorOut" />

<cfif IsJSON (jsonInfo)>
   <cfset videoInfo = DeserializeJSON (jsonInfo)>
   <cfdump var="#videoInfo#">
   <cfset duration = videoInfo.format.duration>
   <cfloop array="#videoInfo.streams#" index="stream">
      <cfif stream.codec_type EQ "video">
         <cfset width = stream.width>
         <cfset height = stream.height>
         <cfbreak />
      </cfif>
   </cfloop>
</cfif>

Solution 4

It is possible to do it with ffmpeg and if you don't want to save the info into a file you just could send it to /dev/null in *nix systems.

ffmpeg -i file.mp4 -hide_banner -f null /dev/null
Share:
76,674
Redtopia
Author by

Redtopia

Updated on July 05, 2022

Comments

  • Redtopia
    Redtopia almost 2 years

    I'm using ffmpeg to get info about a video file and I don't want to save the info into a file. ffmpeg is returning all the video info, but it's returning as an error because I'm not specifying an output file. The command I'm using is:

     ffmpeg -i C:\Test\3FA8D0E6-BD61-D160-98BB41304D63FAE3.mp4
    

    The error I get is "At least one output file must be specified"

    I'm calling this in ColdFusion using <cfexecute>, and the output is being stored in a local variable, which is why I don't want to specify a file... I just don't need to store this in a file.

    If it makes any difference, I'm running this on Windows.

  • Redtopia
    Redtopia almost 12 years
    Using ffprobe is the way to go. I'm outputting the results as JSON and then deserializing them into a native coldfusion struct. Pretty slick.
  • blahdiblah
    blahdiblah almost 12 years
    Yeah, ffprobe is not widely known enough for how useful it is.
  • Some Guy on the Internet
    Some Guy on the Internet almost 12 years
    Maybe the error message in ffmpeg could be changed to suggest this.
  • user2173353
    user2173353 over 8 years
    This is how you use ffProbe : ffprobe -v quiet -print_format json -show_format -show_streams -print_format json "C:\Files\somefile.asf" or to get XML : ffprobe -v quiet -print_format json -show_format -show_streams -print_format xml "C:\Files\somefile.asf". THis will help people get started because the docs seem messy...
  • llogan
    llogan almost 4 years
    This can take a long time because it will initiate decoding of the whole file. No practical advantage compared to just ffmpeg -i input.mp4.
  • O.Badr
    O.Badr almost 4 years
    @llogan Exit code of ffmpeg -i input.mp4 command won't be 0, and in case you need to just get media info in a clean way (using ffmpeg), like sometimes in a Shell/Batch script