Spandan Thakur
Spandan Thakur

Reputation: 368

Which codecs were used in transcoding of a video using ffmpeg

During a transcoding of a video how can I figure out which codecs were used by ffmpeg to decode and transcode the video.

For eg. when I do ffmpeg -i input.mp4 output.avi

How can I know which codecs where used to decode the input file and encode to the output?

Upvotes: 0

Views: 298

Answers (2)

Gyan
Gyan

Reputation: 93329

@Koby Douek's answer is not applicable here.

Mediainfo and ffprobe will indicate the bitstream syntax but to answer the OP's Q: "How can I know which codecs where used to decode the input file and encode to the output?", one can run

ffmpeg -i input.mp4 output.avi 2>&1 | sed -n "/Stream mapping/,/Press/p"

whose output will be like

  Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help

This informs us that the first output stream mapped was the 2nd input stream, of type H.264 and decoded using ffmpeg's native H.264 decoder. This stream was encoded to H.264 using the libx264 encoder.

The given command actually performs the conversion, but the mapping info is displayed just before processing starts, so either abort the command or redirect the log to file by adding -report and parse that file for the info.

Upvotes: 2

Koby Douek
Koby Douek

Reputation: 16693

If you have mediainfo:

mediainfo --Inform="Video;%Codec%" output.avi

If not, use ffprobe (comes with ffmpeg installation):

ffprobe -v error -select_streams v:0 -show_entries stream=codec_name \ -of default=noprint_wrappers=1:nokey=1 output.avi

Upvotes: 1

Related Questions