1

I am trying to find out why the result of using scale2ref with overlay complex filters is returning audio-only mp4 output.

ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[video][logo]overlay=5:H-h-5" -c:a copy output.mp4

If I remove the scale2ref filter, then the output is a mp4 video.

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=5:H-h-5" -c:a copy output.mp4

One of the differences between the two is this line in the output:

[vost#0:0/libx264 @ 0x10f605de0] No filtered frames for output stream, trying to initialize anyway.

I am new to ffmpeg, any help will be appreciated.

Link to the log file

5
  • Which version ?
    – Gyan
    Commented May 2 at 4:25
  • 1
    @Gyan latest 7.0 according to log.
    – Destroy666
    Commented May 2 at 12:16
  • 2
    try to add -loop 1ffmpeg -i "input.mp4" -loop 1 -i watermark.png -lavfi " [1][0]scale2ref=w=oh*mdar/sar:h=ih/10[l][v]; [v][l]overlay=5:H-h-5:shortest=1" output.mp4 Commented May 2 at 13:55
  • Thanks, @БаярГончикжапов! I can see the output with audio and video however the command never finishes. I had to interrupt manually. The output before interruption was: frame=942170 fps=2243 q=-1.0 Lsize= 180036KiB time=00:07:56.91 bitrate=3092.5kbits/s dup=154642 drop=0 speed=1.14x Could this be due to the -loop 1 option?
    – Sushil
    Commented May 3 at 6:23
  • check this option of overlay → ...:shortest=1 Commented May 3 at 12:07

2 Answers 2

1

It looks like the 'scale2ref' filter is broken in the latest version of FFmpeg. It has been deprecated.

I have been experiencing the same problem as you, and when I tried some tricks to get around it, I got Assertion best_input >= 0 failed.

That led me to this question, and it also led me to this issue in the FFmpeg issue tracker: https://trac.ffmpeg.org/ticket/10795.

The 'scale2ref' filter was officially deprecated in this commit: https://github.com/FFmpeg/FFmpeg/commit/95568c4e316e8f5f3252596b1f01ce1de22216b6.

According to some of the commit messages and the communication in that issue, the FFmpeg developers plan to replace 'scale2ref' with the 'scale' filter by adding new reference options 'ref_w' and 'ref_h' to achieve the same functionality.

0

As mentioned in other comments, scale2ref is deprecated. If you're using a recent version of ffmpeg, you should use scale=rw:rh instead when using a reference to scale. Since scale has only one output, just remove the tag [video] after the filter and replace its use with the second input used with scale2ref.

The command would end up as below:

ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1][0]scale=w=oh*mdar:h=rh*0.1[logo];[0][logo]overlay=5:H-h-5" -c:a copy output.mp4

In summary:

  • Replace scale2ref with scale
  • Replace any iw and ih with rw and rh
  • Leave only one output after scale
  • Replace any use of the second output of scale2ref with its second input

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .