4

I am converting some videos with below command in ffmpeg

ffmpeg -y -i source.mp4 -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts keyint=24:min-keyint=24:no-scenecut -crf 18 -b:v 4000k -maxrate 4000k -bufsize 4000k -vf "scale=-1:1080" destination_1080.mp4

But in some cases the output video is exactly double size of the original and the second part is without audio. Please help.

mridul4c
  • 8,197
  • 3
  • 19
  • 28

2 Answers2

2

First thing, there's a flaw in your command. You can't use: -crf 18 -b:v 4000k together, use one or the other.

I don't know what version of FFMPEG you are using, but with the inclusion of: libfdk_aac it's either an old version or one you have self compiled. If I remember correctly that audio codec was taken out of the common builds once the standard aac encoder matured. (I may be wrong about that)

First thing I'd try is to narrow things down a little. From your command line I'm guessing you have a Windows PC, download the latest FFMPEG from HERE

Here are some examples to try: (change audio codec if needed)

BITRATE

ffmpeg -y -i source.mp4 -c:v libx264 -x264opts keyint=24:min-keyint=24:no-scenecut -b:v 4000k -maxrate 4000k -bufsize 4000k -vf "scale=-1:1080" -c:a aac -ac 2 -ab 128k destination_1080_bit.mp4

CRF

ffmpeg -y -i source.mp4 -c:v libx264 -x264opts keyint=24:min-keyint=24:no-scenecut -crf 18 -maxrate 4000k -bufsize 4000k -vf "scale=-1:1080" -c:a aac -ac 2 -ab 128k destination_1080_crf18.mp4

It's interesting you mention the video is twice the size and the audio finishing in the second part.

Your output size will be greater if the bitrate used is higher than the original. Higher the crf value, or lower the bitrate, and have a few tests.

There may also be some FPS issue where the video and audio are mismatched, maybe one thinks the other is at double frame rate. (that's a complete guess)

I would give the above a try first and see how you get on before digging deeper.

Let us know how you get on.

video.baba
  • 817
  • 2
  • 6
  • 11
  • Thanks for the reply @video.baba. I tried the commands, but the problem still persists. For your information I am using Macos for the conversion. – mridul4c Oct 01 '18 at 03:14
  • libvo_aacenc, libfaac, and libaacplus are the [old, removed AAC encoders](https://trac.ffmpeg.org/wiki/Encode/AAC#DeprecatedRemovedEncoders). – llogan Oct 03 '18 at 18:13
0

I'll post a new answer, rather than edit other answer, as my first answer is already rather long.

First, I would try to get to the bottom of the problem by starting simple and working my way up on the problematic file/s.

Just copy source to destination:

ffmpeg -i source.mp4 -c copy destination_1.mp4

Is the ouptut as expected? Any errors? What did FFMPEG display?

Copy video - encode audio:

ffmpeg -i source.mp4 -c:v copy -c:a libfdk_aac -ac 2 -ab 128k destination_2.mp4

Is the ouptut as expected? Any errors? What did FFMPEG display?

Encode video (simple) - encode audio:

ffmpeg -i source.mp4 -c:v libx264 -b:v 4000k -maxrate 4000k -bufsize 4000k -c:a libfdk_aac -ac 2 -ab 128k destination_3.mp4

Is the ouptut as expected? Any errors? What did FFMPEG display?

Encode video (+opts) - encode audio:

ffmpeg -i source.mp4 -c:v libx264 -x264opts keyint=24:min-keyint=24:no-scenecut -b:v 4000k -maxrate 4000k -bufsize 4000k -c:a libfdk_aac -ac 2 -ab 128k destination_4.mp4

Is the ouptut as expected? Any errors? What did FFMPEG display?

Encode video (+filter) - encode audio:

ffmpeg -i source.mp4 -c:v libx264 -x264opts keyint=24:min-keyint=24:no-scenecut -b:v 4000k -maxrate 4000k -bufsize 4000k -filter:v "scale=1920:-2" -c:a libfdk_aac -ac 2 -ab 128k destination_5.mp4

Is the ouptut as expected? Any errors? What did FFMPEG display?

If you still get problems it's going to be difficult to fix or make further suggestions without us seeing the output from FFMPEG.

Remember, don't use -crf 18 -b:v 4000k in the same command, one or the other, cfr OR bitrate, not both.

Best of luck...

video.baba
  • 817
  • 2
  • 6
  • 11