I often have problems reading AVI files with my TV's DVD player if they are not DivX or Xvid (e.g., DX50 is not readable).
I'd like to make a fast script to determine the video codec of these files before burning them to CD-ROM or DVD.
The command
ffmpeg -i file.avi
prints the "container" of the video stream (mpeg4, mpeg2, etc), not the codec.
Any hint?
Thanks
ffmpeg has it. On mac i did it this way :
first download ffmpeg like this:
and then run this on the command line:
then check for something like this in the output:
Duration: 00:00:05.48, start: 0.000000, bitrate: 952 kb/s Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 750x1334, 619 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
FFmpeg gives the codec too. Pull the
Stream #0.0: Video
line and you can see the codec. (Be aware that it could technically have a different stream number, like 0.1.) The below output uses the MS Video-1. This is different, like you desire, from the container which is denoted byInput #0, avi
E.g.:
mediainfo
will in my case return:
Answer made possible thanks to How to find duration of a video file using mediainfo in seconds or other formats?
ffprobe (ffmpeg) easy way
Assuming your video has one video stream only:
Will in my case return:
Answer made possible thanks to How to get video duration in seconds?
ffprobe (ffmpeg) dirty way
This method is easier to understand but messy.
To get the codec information without playing back the file, use
ffprobe
.To extract the video codec information - since ffmpeg sends information to stderr - pipe and grep it:
To reduce the output even further, introduce sed:
Try MediaInfo instead.
It lists the codec for each stream and its output is simple enough to parse - there's also an XML output option if you prefer XPath like queries.