0

Given an audio and an image we create a static image "video" and then append a short clip that has a rather intense motion.

Audio and image varies from run to run. Appended animation is always the same. Rendering is done with ffmpeg on a remote server. Rendered file must be in h264 codec mpg.

Speed of encoding is crucial. Is there a fast and effective way to generate and merge the two clips quickly?

Atm we use the following ffmpeg commands:

// create first clip from image
ffmpeg -loop 1 -r 24 -i $IMAGE -i $AUDIO -t $AUDIO_LENGTH -c:a aac -profile:a aac_low -ar 48000 -b:a 192k -bsf:a aac_adtstoasc -strict -2 -y -c:v libx264 -profile:v high -preset veryfast  -tune stillimage -crf 24 -x264opts bframes=2 -pix_fmt yuv420p -safe 0  clip1.mpg
// . . .
// then append the animation
ffmpeg -f concat -safe 0 -i list.txt -c copy -y -safe 0 final.mpg 

Intuition is that we can benefit form knowing exact timing of a first clip with a static image and the second one with intense animation – like it is determined in the 1-st pass of a 2-pass compression.

Someone experienced in tech of h264 codec and mpeg please advice.

Serge
  • 1,531
  • 2
  • 21
  • 44
  • You can do it in one command with the concat filter. You'll have to resize one of the inputs to the other. – Gyan Feb 14 '17 at 18:24
  • That's true and **it takes long**, because the static image video has to be rendered with the framerate / b-frames rate and other parameters of the animated clip. – Serge Feb 14 '17 at 18:35
  • What command are you presently using to make the image clip? And what's the properties of the tail clip? – Gyan Feb 14 '17 at 18:52
  • @Mulvya I added command examples to the question. Appended clip: Duration: 00:00:03.19, bitrate: 263 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 77 kb/s, 24 fps, 24 tbr, 12288 tbn (default) Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 181 kb/s (default) – Serge Feb 14 '17 at 19:12
  • Is the added command the one that "*generate the static image clip much faster*"? – Gyan Feb 14 '17 at 19:23
  • In your first command you can replace the `-r 24` input option with the `-framerate 1` input option, then add `-r 24` as an output option. Will likely be somewhat faster. Also, you don't need `-safe 0` in your first command, and you don't need `-safe 0` as an output option in your second command: that's an input option for the concat demuxer only. Also, you need to show the complete console output from your commands: there may be more we can suggest based on that info. – llogan Feb 14 '17 at 20:35

0 Answers0