1

I want to generate a video with the exact same settings as an existing video. I can run:

ffmpeg -i original.mp4

To get human-readable info about the contents:

Duration: 00:05:32.32, start: 0.000000, bitrate: 474 kb/s
  Stream #0.0(und): Video: h264, yuv420p, 480x360, 25 tbr, 25 tbn, 50 tbc
  Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16

But what I'd like is to get the command-line I'd need to convert another video into the exact same format, so something like:

ffmpeg -i source.mp4 -vcodec h264 - ....

Any ideas if such a thing is possible?

  • To create an h264 video with ffmpeg/libav you need libx264. With it installed you would do ffmpeg ... -vcodec x264 ... Mapping the rest of the options can be difficult though since the usual ones don't apply, here is a guide - trac.ffmpeg.org/wiki/x264EncodingGuide – Graeme Apr 7 '14 at 14:47
2

There is no built-in option to do this, so you would need to write a program to do it.

You need to parse the output of ffmpeg -i. Then you need to build a string containing all of the relevant information, formatted as a command line. It would need to know how to handle any properties that concern you. As Graeme noted, some format options are reported differently from the command you need to make them (and these often depend on the specific component that you have installed). Occasionally the completed script would need to be updated because of changes in ffmpeg.

It's definitely possible, but it would be difficult and time-consuming. It might not be worth doing. If you still want to try it, you'll probably need experience in these areas:

  • regular expressions

  • media encoding in general

  • ffmpeg options and components (I recommend compiling it yourself if you haven't already)

  • (probably) a good dynamic programming language (PERL seems like a logical candidate, if you can understand it)

By the time you finish, you might find that you prefer to type in your own command lines anyway.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.