2

I have many-many video files in different formats (mostly avi). For example, some relevant lines from ffprobe:

  Duration: 02:27:14.70, start: 0.000000, bitrate: 664 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 608x256 [PAR 1:1 DAR 19:8], 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0.1: Audio: mp3, 44100 Hz, stereo, s16, 96 kb/s

  Duration: 00:20:51.84, start: 0.000000, bitrate: 3286 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
    Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s

  Duration: 01:26:01.84, start: 0.000000, bitrate: 845 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 704x544 [PAR 1:1 DAR 22:17], 25 fps, 25 tbr, 25 tbn, 30k tbc
    Stream #0.1: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s

  Duration: 01:42:25.68, start: 0.000000, bitrate: 952 kb/s
    Stream #0.0: Video: h264 (High), yuv420p, 600x244 [PAR 1:1 DAR 150:61], 25 fps, 25 tbr, 25 tbn, 50 tbc
    Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 112 kb/s

As you can see, the bitrates, video-sizes, codecs are vary. Want write a script (bash, perl) what will convert them for iPhone with ffmpeg.

With googling i found many different ffmpeg profiles, but all profiles are "static", e.g. converts video to same resolution and this is probably not the right way, because i have many different video resolutions with many different bitrates. (this applies for the audio too).

I'm able write the script - but need help with one basic question.

I need help with the algorithm how to calculate the values for ffmpeg arguments from the above ffprobe results. E.g. when have video 704x544 and 845kb/s and another video with smaller size 640x480 but 3200kb/s bitrate - how to calculate the "right values" for ffmpeg in the script?

What is right algorithm/logic for transcoding video for the desired device? (in my case iPhone)

If someone care, I have ffmpeg recompiled with "nonfree" codecs, and have mencoder (from mplayer package) too.

Second: In the avi containers are many videos already in the mpeg4 format. How to determine the "fastest" converting profile? Mean a profile, where ffmpeg will only do the less-possible calculations, so probably will leave as-is: the format mpeg4, the size, the bitrate and "only" will change the container format. Is this possible?

I was read many ffmpeg SO questions, but not find answers - maybe I missed something. Can somebody point me to some good documents?

cajwine
  • 3,100
  • 1
  • 20
  • 41

1 Answers1

0

Did you try using gstreamer? If so, you could run a command-line gst-launch that would auto-decode any input file, then resize to any format you need, then re-encode and re-mux into a mov file. The exact line depends on the presence/absence of audio, and the concrete codec to be using for writing the .mov files.

An example reencoding XYZ -> ABC.mov, with no audio, for 320x240 resizing and h263 encoding:

gst-launch   filesrc location=XYZ ! decodebin2 ! ffmpegcolorspace ! videoscale add-borders=true ! video/x-raw-yuv, width=320, height=240 ! ffmpegcolorspace ! ffenc_h263 ! qtmux ! filesink location=ABC.mov
miguelao
  • 772
  • 5
  • 12
  • 1
    And about what I asking is excatly about this: __then resize to any format you need__. When you have 10000 files, it is impossible test them manually - need some logic (algorithm) how to determine the BEST format for the given file. Thank you anyway for answer. ;) – cajwine Sep 28 '12 at 21:04