diff --git a/examples/overlay.py b/examples/overlay.py
index 800fa90..a7926c7 100644
--- a/examples/overlay.py
+++ b/examples/overlay.py
@@ -11,7 +11,7 @@ overlay = ff.video | Overlay(x=1720, y=100)
 # scale logo to 100x100 and pass as top layer to overlay filter
 logo | Scale(width=100, height=100) | overlay
 
-# tell ffmpeg that it'll output something to destination file
-output = ff > output_file('output.mp4')
 # output video with logo to destination file
-overlay > output
+output = overlay > output_file('output.mp4', VideoCodec('libx264'))
+# tell ffmpeg that it'll output something to destination file
+ff > output
diff --git a/fffw/encoding/outputs.py b/fffw/encoding/outputs.py
index 267c59d..4d0e471 100644
--- a/fffw/encoding/outputs.py
+++ b/fffw/encoding/outputs.py
@@ -110,7 +110,7 @@ class Output(BaseWrapper):
     format: str = param(name="f")
     output_file: str = param(name="", skip=True)
 
-    def __lt__(self, other: base.InputType) -> Codec:
+    def __lt__(self, other: base.InputType) -> "Output":
         """
         Connects a source or a filter to a first free codec.
 
@@ -118,7 +118,7 @@ class Output(BaseWrapper):
         """
         codec = self.get_free_codec(other.kind)
         other.connect_dest(codec)
-        return codec
+        return self
 
     @property
     def video(self) -> Codec:

FFMPEG.add_output shortcuts imisbehaving
```
output = ff > output_file('output.mp4', VideoCodec('libx264'))

stream > output
```
The code above does not work because second line raises "no free codecs" error.

Relates to #43
diff --git a/tests/test_ffmpeg.py b/tests/test_ffmpeg.py
index dcb2105..10e52e3 100644
--- a/tests/test_ffmpeg.py
+++ b/tests/test_ffmpeg.py
@@ -493,3 +493,19 @@ class FFMPEGTestCase(BaseTestCase):
         ff > output
 
         ff.check_buffering()
+
+    def test_shortcut_outputs_with_codec(self):
+        """ Check ff > output shortcut if codecs list specified."""
+        ff = FFMPEG(input=inputs.input_file("input.mp4"))
+        scaled = ff.video | filters.Scale(width=1280, height=720)
+
+        with self.assertRaises(RuntimeError):
+            codec = codecs.VideoCodec("libx264")
+            out = ff > outputs.output_file("output.mp4", codec)
+            # at this moment codec is connected to ffmpeg input stream directly
+            # so scaled video stream could not be connected to output
+            scaled > out
+
+        codec = codecs.VideoCodec("libx264")
+        out = scaled > outputs.output_file("output.mp4", codec)
+        ff > out

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y ffmpeg mediainfo
3.8
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup==1.2.2
-e git+https://github.com/just-work/fffw.git@bb6d4bc134f17b0813d82eac027b6eb82a8ccbe3#egg=fffw
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pymediainfo==4.2.1
pytest==8.3.5
tomli==2.2.1

name: fffw
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=24.2=py38h06a4308_0
  - python=3.8.20=he870216_0
  - readline=8.2=h5eee18b_0
  - setuptools=75.1.0=py38h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.44.0=py38h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pymediainfo==4.2.1
      - pytest==8.3.5
      - tomli==2.2.1
prefix: /opt/conda/envs/fffw

tests/test_ffmpeg.py::FFMPEGTestCase::test_shortcut_outputs_with_codec
tests/test_ffmpeg.py::FFMPEGTestCase::test_bypass_with_filter_complex tests/test_ffmpeg.py::FFMPEGTestCase::test_bypass_without_filter_complex tests/test_ffmpeg.py::FFMPEGTestCase::test_concat tests/test_ffmpeg.py::FFMPEGTestCase::test_detect_concat_buffering tests/test_ffmpeg.py::FFMPEGTestCase::test_detect_trim_buffering tests/test_ffmpeg.py::FFMPEGTestCase::test_ffmpeg tests/test_ffmpeg.py::FFMPEGTestCase::test_fix_preroll_buffering_with_trim tests/test_ffmpeg.py::FFMPEGTestCase::test_handle_codec_copy tests/test_ffmpeg.py::FFMPEGTestCase::test_handle_codec_copy_with_other_filters tests/test_ffmpeg.py::FFMPEGTestCase::test_input_stream_naming tests/test_ffmpeg.py::FFMPEGTestCase::test_no_audio_if_no_codecs_found tests/test_ffmpeg.py::FFMPEGTestCase::test_reuse_input_files tests/test_ffmpeg.py::FFMPEGTestCase::test_transcoding_without_graph
fffw/encoding/outputs.py examples/overlay.py
fffw/encoding/outputs.py examples/overlay.py