Answers.Body: <p>I've been on a 5 week holiday and have had this exact same problem. It has taken me a long time to figure all this out, but I think I've nailed it.</p>
  <p>My source was a PAL VHS recorded to HUFFYUV avi. recording top and bottom fields in a frame. i.e. 25p.. 50 fields per second</p>
  <p><code>ffprobe.exe &quot;my input video.avi&quot;</code> returns</p>
  <pre><code>Input #0, avi, from 'nov 81 084.avi':
    Duration: 00:00:13.44, start: 0.000000, bitrate: 77673 kb/s
    Stream #0:0: Video: huffyuv (HFYU / 0x55594648), yuv422p, 720x576, 76993 kb/s, 25 fps, 25 tbr, 25 tbn
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
  </code></pre>
  <p>Input is a video marked as progressive, containing two fields.
  If VLC is told to deinterlace the video, it does so successfully, the issue is that VLC does not do it by <strong>default</strong> .</p>
  <pre><code>┌----------┐----------┐----------┐
  | Frame 1  | Frame 2  | Frame 3  |
  | 0.00 sec | 0.04 sec | 0.08 sec |
  ├----------┼----------┼----------┤
  | 111      | 333      | 555      |
  | 222      | 444      | 666      |
  | 111      | 333      | 555      |
  | 222      | 444      | 666      |
  └----------┴----------┴----------┘
  </code></pre>
  <p>Numbers meaning in table above:</p>
  <ol>
  <li>111 is field recorded at 0.00 sec</li>
  <li>222 is field recorded at 0.02 sec</li>
  <li>333 is field recorded at 0.04 sec</li>
  <li>444 is field recorded at 0.06 sec</li>
  <li>555 is field recorded at 0.08 sec</li>
  <li>666 is field recorded at 0.10 sec</li>
  </ol>
  <p>Background reading:</p>
  <p><a href="https://ffmpeg.org/ffmpeg.html" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg.html</a> for <code>x264 x265</code> options</p>
  <p><a href="https://ffmpeg.org/ffmpeg-filters.html" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-filters.html</a> for all the <code>-vf</code> options</p>
  <p><a href="https://x265.readthedocs.io/en/master/cli.html#input-output-file-options" rel="nofollow noreferrer">https://x265.readthedocs.io/en/master/cli.html#input-output-file-options</a> for x265 encoder options</p>
  <p><a href="https://ffmpeg.org/ffmpeg-codecs.html#libx264_002c-libx264rgb" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-codecs.html#libx264_002c-libx264rgb</a> for x264 encoder options</p>
  <p>I believe the *<em>correct</em> answer, creating an 480i file is my <code>Option 1.</code> and <code>Option 2.</code> below.</p>
  <p>The OP <strong>Output 1</strong> is created from my <code>Option 3.</code> and <code>Option 4.</code></p>
  <p>The OP <strong>Output 2</strong> is created from my <code>Option 3.</code> and <code>Option 4.</code> using <code>-vf field_order bb</code> directly after the <code>-i input.avi</code></p>
  <ol>
  <li>x264 interlaced 25i (50 fields per second) visually lossless</li>
  <li>x265 interlaced 25i (50 fields per second) visually lossless</li>
  <li>x264 progressive 50p (50 frames per second) YUV420 - for modern tvs - chromecast 2/3</li>
  <li>x265 progressive 50p (50 frames per second) YUV420 - for chromecast ultra / google tv</li>
  </ol>
  <h2>Option 1.</h2>
  <p>The meta data on the output says it is interlaced top field first, so VLC will correctly deinterlace it on playback. I believe this is the best format to store the video, because it is staying true to the source, with no interpolation (which might improve in 10 years time).</p>
  <pre><code>┌---------------------┐---------------------┐---------------------┐
  |       Frame 1       |       Frame 1       |       Frame 1       |
  | Field 1  | Field 2  | Field 1  | Field 2  | Field 1  | Field 2  |
  | 0.00 sec | 0.02 sec | 0.04 sec | 0.06 sec | 0.08 sec | 0.10 sec |
  ├----------┼----------┼----------┼----------┼----------┼----------┤
  | 111      | ---      | 333      | ---      | 555      | ---      |
  | ---      | 222      | ---      | 444      | ---      | 666      |
  | 111      | ---      | 333      | ---      | 555      | ---      |
  | ---      | 222      | ---      | 444      | ---      | 666      |
  └----------┴----------┴----------┴----------┴----------┴----------┘
  </code></pre>
  <pre><code>ffmpeg.exe -i &quot;my input video.avi&quot; -field_order tt 
    -c:v libx264 -crf 18 -preset veryslow -x264opts tff=1 -weightp none 
    -c:a aac -b:a 128k 
    &quot;my output video.mp4&quot;
  </code></pre>
  <p>Play around with <code>-field_order tt</code> <a href="https://ffmpeg.org/ffmpeg-codecs.html" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-codecs.html</a></p>
  <pre><code>field_order field_order (video)
  
      Set/override the field order of the video. Possible values:
  
      ‘progressive’
          Progressive video 
  
      ‘tt’
          Interlaced video, top field coded and displayed first 
  
      ‘bb’
          Interlaced video, bottom field coded and displayed first 
  
      ‘tb’
          Interlaced video, top coded first, bottom displayed first 
  
      ‘bt’
          Interlaced video, bottom coded first, top displayed first 
  </code></pre>
  <p>Results in the following file, my hint I got it right was <code>top first</code>.</p>
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'my output video.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf59.16.100
    Duration: 00:15:55.16, start: 0.000000, bitrate: 13099 kb/s
    Stream #0:0[0x1](und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p(top first), 720x576, 12964 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  </code></pre>
  <h2>Option 2.</h2>
  <p>Has all the same characteristics as <code>Option 1.</code> but it is h265 so results in smaller files. When running ffmpeg, it will give you a warning <code>x265 [warning]: Support for interlaced video is experimental</code></p>
  <p>I have found the experiment to be very successful, the VMAF (below) suggests the content is visually identical.</p>
  <pre><code>ffmpeg.exe -i &quot;my input video.avi&quot; -field_order tt 
    -c:v libx265 -x265-params interlace=tff -crf 23 -preset veryslow
    -c:a aac -b:a 128k 
    &quot;my output video.mp4&quot;
  </code></pre>
  <p>Results in the following file, my hint was the (tv, top first), Meaning the <code>tv</code> is the colour space (16-240) instead of <code>pc</code> 0-255</p>
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '01 nov 81 060 -field_order tt x265-ttf crf23 win64.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf59.16.100
    Duration: 00:15:55.16, start: 0.000000, bitrate: 5502 kb/s
    Stream #0:0[0x1](und): Video: hevc (Rext) (hev1 / 0x31766568), yuv422p(tv, top first), 720x576, 5368 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  </code></pre>
  <h2>Option 3.</h2>
  <pre><code>┌----------┐----------┐----------┐----------┐----------┐----------┐
  | Frame 1  | Frame 2  | Frame 3  | Frame 4  | Frame 5  | Frame 6  |
  | 0.00 sec | 0.02 sec | 0.04 sec | 0.06 sec | 0.08 sec | 0.10 sec |
  ├----------┼----------┼----------┼----------┼----------┼----------┤
  | 111      | 2**      | 333      | 4**      | 555      | 6**      |
  | 1**      | 222      | 3**      | 444      | 5**      | 666      |
  | 111      | 2**      | 333      | 4**      | 555      | 6**      |
  | 1**      | 222      | 3**      | 444      | 5**      | 666      |
  └----------┴----------┴----------┴----------┴----------┴----------┘
  </code></pre>
  <p>The video is encoded as progressive, doubling the frame rate, now at 50p.
  1** Interpolate the missing fields. Doubler. <a href="https://wiki.videolan.org/Deinterlacing/#Doublers" rel="nofollow noreferrer">https://wiki.videolan.org/Deinterlacing/#Doublers</a></p>
  <pre><code>ffmpeg.exe  -i &quot;my input video.avi&quot; -vf format=yuv420p,yadif=mode=send_field 
    -c:v libx264 -crf 18 -preset veryslow 
    -c:a aac -b:a 128k
    &quot;my output video.mp4&quot;
  </code></pre>
  <p>Results in a progressive file for 50 frames per second from the yadif 2x.</p>
  <p>If you find that it looks crap, because it is bottom field first, experiement with addind <code>-field_order xx</code> after the <code>-i filename.avi</code> part</p>
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'my output video.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf59.16.100
    Duration: 00:00:13.52, start: 0.000000, bitrate: 6658 kb/s
    Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 720x576, 6521 kb/s, 50 fps, 50 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  </code></pre>
  <h2>Option 4.</h2>
  <p>Has all the same characteristics as <code>Option 3.</code> but it is h265 so results in smaller files. When running ffmpeg, it will give you a warning <code>x265 [warning]: Support for interlaced video is experimental</code></p>
  <p>I have found the experiment to be very successful, the VMAF (below) suggests the content is visually identical.</p>
  <pre><code>ffmpeg.exe -i &quot;my input video.avi&quot; -vf format=yuv420p,yadif=mode=send_field
    -c:v libx265 -crf 23 -preset veryslow 
    -c:a aac -b:a 128k
    &quot;my output video.mp4&quot;
  </code></pre>
  <p>Results in a progressive file for 50 frames per second from yadif 2x</p>
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '01 nov 81 084 yadif x2 x265 crf23.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf59.16.100
    Duration: 00:00:13.52, start: 0.000000, bitrate: 3806 kb/s
    Stream #0:0[0x1](und): Video: hevc (Rext) (hev1 / 0x31766568), yuv420p(tv, progressive), 720x576, 3667 kb/s, 50 fps, 50 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  </code></pre>
  <h2>Objective quality analysis of output</h2>
  <p>Compare how visually lossy your chosen <code>-crf</code> number was:</p>
  <pre><code>ffmpeg -i &quot;my output video.mp4&quot; -i &quot;my input video.avi&quot; -lavfi libvmaf=log_path=output.xml -f null -
  </code></pre>
  <p>I got around 97-96% with my 720x576. However I read that <code>-lavfi</code> thing does its best work at 1080p. <a href="https://github.com/Netflix/vmaf/blob/master/resource/doc/faq.md" rel="nofollow noreferrer">https://github.com/Netflix/vmaf/blob/master/resource/doc/faq.md</a></p>
  <p>So scaling both videos to get a true value from <code>Option 1.</code> and <code>Option 2.</code> never got above 88.</p>
  <pre><code>ffmpeg.exe -i &quot;my output video.mp4&quot; -i &quot;my input video.avi&quot; -filter_complex &quot;[0:v]yadif=1:0:0,scale=1920x1080:flags=bicubic[main];[1:v]yadif=1:0:0,scale=1920x1080:flags=bicubic[ref];[main][ref]libvmaf&quot; -f null -
  </code></pre>
  <p><code>yadif=1:0:0</code> means to go to 50fps <a href="https://ffmpeg.org/ffmpeg-filters.html#yadif-1" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-filters.html#yadif-1</a></p>
  <p>For <code>Option 3.</code> and <code>Option 4.</code> the yadif filter isn't required.</p>
  <pre><code>ffmpeg.exe -i &quot;my output video.mp4&quot; -i &quot;my input video.avi&quot; -filter_complex &quot;[0:v]scale=1920x1080:flags=bicubic[main];[1:v]scale=1920x1080:flags=bicubic[ref];[main][ref]libvmaf&quot; -f null -
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-18T21:37:16.363Z
Answers.LastActivityDate: 2022-08-19T18:59:00.967Z
Answers.LastEditDate: 2022-08-19T18:59:00.967Z
Answers.UserDisplayName: Clive Gout
Answers.Body: <p>This seems to do what you want. <code>il</code> moves the odd lines to the top of the frame, and even lines to the bottom. Then <code>split</code> just creates 2 copies of this. We then <code>crop</code> both copies, to only include the top or the bottom. Finally, <code>framepack</code> will alternate frames from those two streams.</p>
  <pre><code>ffmpeg -i input.mkv -c:v libx265 -filter_complex '[0:v]il=l=d:c=d,split[t0][b0];[t0]crop=720:240:0:0[t1];[b0]crop=720:240:0:240[b1];[t1][b1]framepack=frameseq' output.mkv
  </code></pre>
  <p>But usually <code>yadif</code> can fix messed up videos like that, unless they also did something else to it to mess up the pattern too much. And if that's the case, this won't fix it either.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-02T22:26:30.513Z
Answers.Text: It works inasmuch as the resulting video does have alternating frames that only contain odd and even fields. Judder is visible between frames, so it's clear that it worked.  
  
  So far so good.  
  
  Any way how to mark that these are actually fields in an interlaced video rather than a progressive video at twice the speed? I copied the _incomplete_ file in progress into another to watch the result and unless there is something meant to be written to the end of file, VLC doesn't seem to recognize the video for what it should be.
Answers.UserDisplayName: toughluck
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-04T17:19:46.357Z
Answers.Text: I think that's a codec option. `-x265-params interlaced=1` or 2.
Answers.UserDisplayName: stribika
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-09T11:26:18.343Z
Answers.Text: I found it's -x265-params interlace=tff or bff, while it's -x264-params interlaced=1 or 2. I assume it works, but neither plays correctly. Both are shown at 640x240 at 50 fps with judder visible. I wonder if it's a video player problem now, but I'm using VLC, so it doesn't seem like it should be an issue.
Answers.UserDisplayName: toughluck
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-09T12:37:19.327Z
Answers.Text: I tinkered a bit with it. It seems that field order is reversed, bottom field is first, which means I changed the command to this:
  ffmpeg ... -filter_complex '[0:v]il=l=d:c=d,split[t0][b0];...[b1][t1]framepack=frameseq' -x265-params interlace=tff ...
  When I used your command (where it was [t1][b1] and I changed the order), the video was extremely juddery in vertical motion, this judder is gone now.
Answers.UserDisplayName: toughluck
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-29T14:39:57.547Z
Answers.LastActivityDate: 2021-07-29T14:39:57.547Z
Answers.UserDisplayName: stribika
Body: <p>I have a 480p video that was naïvely created from a 480i original and had no deinterlacing applied. The resulting format is 480p25. Combing is visible and I would like to convert it back to 480i50, so sort of &quot;re-interlace&quot; the video back to its original state.</p>
  <p>I have tried the solution from this question: <a href="https://stackoverflow.com/questions/22471099/how-to-convert-a-1080p-to-1080i-using-ffmpeg">https://stackoverflow.com/questions/22471099/how-to-convert-a-1080p-to-1080i-using-ffmpeg</a> but it did not create the expected output.</p>
  <p>I looked at ffmpeg reference here: <a href="https://www.ffmpeg.org/ffmpeg-all.html" rel="nofollow noreferrer">https://www.ffmpeg.org/ffmpeg-all.html</a> but I could not find a proper option. Tons of filters to deinterlace interlaced videos but nothing to &quot;re-interlace&quot; them.</p>
  <p>My expected output would be this:</p>
  <pre><code> ------&gt; time
  Input:
  Frame 1 (0 ms)        Frame 2 (40 ms)
  
  11111                 33333
  22222                 44444
  11111                 33333
  22222                 44444
  
  Output 1:
  Frame 1 (0 ms)  Frame 2 (20 ms) Frame 3 (40 ms) Frame 4 (60 ms)
  11111           22222           33333           44444
  11111           22222           33333           44444
  11111           22222           33333           44444
  11111           22222           33333           44444
  
  (Alternative) Output 2:
  Frame 1 (0 ms)  Frame 2 (20 ms) Frame 3 (40 ms) Frame 4 (60 ms)
  22222           11111           44444           33333
  22222           11111           44444           33333
  22222           11111           44444           33333
  22222           11111           44444           33333
  </code></pre>
  <p>(I'm not sure whether it's top field first or bottom field first, so I'd like to have an option to try both.)</p>
  <p>Is this possible?</p>
  <p>I'd prefer it to use ffmpeg, but I'm open to trying commercial tools if it's not possible using freeware.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-09T17:59:18.893Z
Comments.Text: I think all you need is to specify an output which is interlaced. ffmpeg will do the rest for you.
Comments.UserDisplayName: Alexis Wilke
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-10T17:30:31.300Z
Comments.Text: How do I do that? Pretty much every format supports progressive along with interlaced.
  Also, I believe what ffmpeg would do is it would take unaltered odd lines from each frame, but interlaced frames with even lines would be generated by interpolating even lines from neighboring frames.
Comments.UserDisplayName: toughluck
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-11T00:13:07.053Z
Comments.Text: The odd/even may be an issue where you need to swap to even/odd instead. But otherwise the input has 2x the data necessary. For example, ffmpeg will use odd lines from frame 1, then even lines from frame 2, and repeat until done. So there is no need to do anything special to go from progressive to interlaced.
Comments.UserDisplayName: Alexis Wilke
Tags: <ffmpeg>
Title: How to “re-interlace” a video? How to convert a naïvely deinterlaced 480p video back to 480i?
UserDisplayName: toughluck
ThreadText: # How to “re-interlace” a video? How to convert a naïvely deinterlaced 480p video back to 480i?
  
  (Asked by: username_0 on 2021-07-08)
  
  I have a 480p video that was naïvely created from a 480i original and had no deinterlacing applied. The resulting format is 480p25. Combing is visible and I would like to convert it back to 480i50, so sort of "re-interlace" the video back to its original state.
  
  I have tried the solution from this question: <https://stackoverflow.com/questions/22471099/how-to-convert-a-1080p-to-1080i-using-ffmpeg> but it did not create the expected output.
  
  I looked at ffmpeg reference here: <https://www.ffmpeg.org/ffmpeg-all.html> but I could not find a proper option. Tons of filters to deinterlace interlaced videos but nothing to "re-interlace" them.
  
  My expected output would be this:
  
  ```
   ------> time
  Input:
  Frame 1 (0 ms)        Frame 2 (40 ms)
  
  11111                 33333
  22222                 44444
  11111                 33333
  22222                 44444
  
  Output 1:
  Frame 1 (0 ms)  Frame 2 (20 ms) Frame 3 (40 ms) Frame 4 (60 ms)
  11111           22222           33333           44444
  11111           22222           33333           44444
  11111           22222           33333           44444
  11111           22222           33333           44444
  
  (Alternative) Output 2:
  Frame 1 (0 ms)  Frame 2 (20 ms) Frame 3 (40 ms) Frame 4 (60 ms)
  22222           11111           44444           33333
  22222           11111           44444           33333
  22222           11111           44444           33333
  22222           11111           44444           33333
  
  ```
  
  (I'm not sure whether it's top field first or bottom field first, so I'd like to have an option to try both.)
  
  Is this possible?
  
  I'd prefer it to use ffmpeg, but I'm open to trying commercial tools if it's not possible using freeware.
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: I think all you need is to specify an output which is interlaced. ffmpeg will do the rest for you.  
  > **username_0**: How do I do that? Pretty much every format supports progressive along with interlaced. Also, I believe what ffmpeg would do is it would take unaltered odd lines from each frame, but interlaced frames with even lines would be generated by interpolating even lines from neighboring frames.  
  > **username_1**: The odd/even may be an issue where you need to swap to even/odd instead. But otherwise the input has 2x the data necessary. For example, ffmpeg will use odd lines from frame 1, then even lines from frame 2, and repeat until done. So there is no need to do anything special to go from progressive to interlaced.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2022-08-18. Score: 2
  
  I've been on a 5 week holiday and have had this exact same problem. It has taken me a long time to figure all this out, but I think I've nailed it.
  
  My source was a PAL VHS recorded to HUFFYUV avi. recording top and bottom fields in a frame. i.e. 25p.. 50 fields per second
  
  `ffprobe.exe "my input video.avi"` returns
  
  ```
  Input #0, avi, from 'nov 81 084.avi':
    Duration: 00:00:13.44, start: 0.000000, bitrate: 77673 kb/s
    Stream #0:0: Video: huffyuv (HFYU / 0x55594648), yuv422p, 720x576, 76993 kb/s, 25 fps, 25 tbr, 25 tbn
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
  
  ```
  
  Input is a video marked as progressive, containing two fields.
  If VLC is told to deinterlace the video, it does so successfully, the issue is that VLC does not do it by **default** .
  
  ```
  ┌----------┐----------┐----------┐
  | Frame 1  | Frame 2  | Frame 3  |
  | 0.00 sec | 0.04 sec | 0.08 sec |
  ├----------┼----------┼----------┤
  | 111      | 333      | 555      |
  | 222      | 444      | 666      |
  | 111      | 333      | 555      |
  | 222      | 444      | 666      |
  └----------┴----------┴----------┘
  
  ```
  
  Numbers meaning in table above:
  
  1. 111 is field recorded at 0.00 sec
  2. 222 is field recorded at 0.02 sec
  3. 333 is field recorded at 0.04 sec
  4. 444 is field recorded at 0.06 sec
  5. 555 is field recorded at 0.08 sec
  6. 666 is field recorded at 0.10 sec
  
  Background reading:
  
  <https://ffmpeg.org/ffmpeg.html> for `x264 x265` options
  
  <https://ffmpeg.org/ffmpeg-filters.html> for all the `-vf` options
  
  <https://x265.readthedocs.io/en/master/cli.html#input-output-file-options> for x265 encoder options
  
  <https://ffmpeg.org/ffmpeg-codecs.html#libx264_002c-libx264rgb> for x264 encoder options
  
  I believe the \**correct* answer, creating an 480i file is my `Option 1.` and `Option 2.` below.
  
  The OP **Output 1** is created from my `Option 3.` and `Option 4.`
  
  The OP **Output 2** is created from my `Option 3.` and `Option 4.` using `-vf field_order bb` directly after the `-i input.avi`
  
  1. x264 interlaced 25i (50 fields per second) visually lossless
  2. x265 interlaced 25i (50 fields per second) visually lossless
  3. x264 progressive 50p (50 frames per second) YUV420 - for modern tvs - chromecast 2/3
  4. x265 progressive 50p (50 frames per second) YUV420 - for chromecast ultra / google tv
  
  ## Option 1.
  
  The meta data on the output says it is interlaced top field first, so VLC will correctly deinterlace it on playback. I believe this is the best format to store the video, because it is staying true to the source, with no interpolation (which might improve in 10 years time).
  
  ```
  ┌---------------------┐---------------------┐---------------------┐
  |       Frame 1       |       Frame 1       |       Frame 1       |
  | Field 1  | Field 2  | Field 1  | Field 2  | Field 1  | Field 2  |
  | 0.00 sec | 0.02 sec | 0.04 sec | 0.06 sec | 0.08 sec | 0.10 sec |
  ├----------┼----------┼----------┼----------┼----------┼----------┤
  | 111      | ---      | 333      | ---      | 555      | ---      |
  | ---      | 222      | ---      | 444      | ---      | 666      |
  | 111      | ---      | 333      | ---      | 555      | ---      |
  | ---      | 222      | ---      | 444      | ---      | 666      |
  └----------┴----------┴----------┴----------┴----------┴----------┘
  
  ```
  
  ```
  ffmpeg.exe -i "my input video.avi" -field_order tt 
    -c:v libx264 -crf 18 -preset veryslow -x264opts tff=1 -weightp none 
    -c:a aac -b:a 128k 
    "my output video.mp4"
  
  ```
  
  Play around with `-field_order tt` <https://ffmpeg.org/ffmpeg-codecs.html>
  
  ```
  field_order field_order (video)
  
      Set/override the field order of the video. Possible values:
  
      ‘progressive’
          Progressive video 
  
      ‘tt’
          Interlaced video, top field coded and displayed first 
  
      ‘bb’
          Interlaced video, bottom field coded and displayed first 
  
      ‘tb’
          Interlaced video, top coded first, bottom displayed first 
  
      ‘bt’
          Interlaced video, bottom coded first, top displayed first 
  
  ```
  
  Results in the following file, my hint I got it right was `top first`.
  
  ```
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'my output video.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf59.16.100
    Duration: 00:15:55.16, start: 0.000000, bitrate: 13099 kb/s
    Stream #0:0[0x1](und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p(top first), 720x576, 12964 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  
  ```
  
  ## Option 2.
  
  Has all the same characteristics as `Option 1.` but it is h265 so results in smaller files. When running ffmpeg, it will give you a warning `x265 [warning]: Support for interlaced video is experimental`
  
  I have found the experiment to be very successful, the VMAF (below) suggests the content is visually identical.
  
  ```
  ffmpeg.exe -i "my input video.avi" -field_order tt 
    -c:v libx265 -x265-params interlace=tff -crf 23 -preset veryslow
    -c:a aac -b:a 128k 
    "my output video.mp4"
  
  ```
  
  Results in the following file, my hint was the (tv, top first), Meaning the `tv` is the colour space (16-240) instead of `pc` 0-255
  
  ```
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '01 nov 81 060 -field_order tt x265-ttf crf23 win64.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf59.16.100
    Duration: 00:15:55.16, start: 0.000000, bitrate: 5502 kb/s
    Stream #0:0[0x1](und): Video: hevc (Rext) (hev1 / 0x31766568), yuv422p(tv, top first), 720x576, 5368 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  
  ```
  
  ## Option 3.
  
  ```
  ┌----------┐----------┐----------┐----------┐----------┐----------┐
  | Frame 1  | Frame 2  | Frame 3  | Frame 4  | Frame 5  | Frame 6  |
  | 0.00 sec | 0.02 sec | 0.04 sec | 0.06 sec | 0.08 sec | 0.10 sec |
  ├----------┼----------┼----------┼----------┼----------┼----------┤
  | 111      | 2**      | 333      | 4**      | 555      | 6**      |
  | 1**      | 222      | 3**      | 444      | 5**      | 666      |
  | 111      | 2**      | 333      | 4**      | 555      | 6**      |
  | 1**      | 222      | 3**      | 444      | 5**      | 666      |
  └----------┴----------┴----------┴----------┴----------┴----------┘
  
  ```
  
  The video is encoded as progressive, doubling the frame rate, now at 50p.
  1\*\* Interpolate the missing fields. Doubler. <https://wiki.videolan.org/Deinterlacing/#Doublers>
  
  ```
  ffmpeg.exe  -i "my input video.avi" -vf format=yuv420p,yadif=mode=send_field 
    -c:v libx264 -crf 18 -preset veryslow 
    -c:a aac -b:a 128k
    "my output video.mp4"
  
  ```
  
  Results in a progressive file for 50 frames per second from the yadif 2x.
  
  If you find that it looks crap, because it is bottom field first, experiement with addind `-field_order xx` after the `-i filename.avi` part
  
  ```
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'my output video.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf59.16.100
    Duration: 00:00:13.52, start: 0.000000, bitrate: 6658 kb/s
    Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 720x576, 6521 kb/s, 50 fps, 50 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  
  ```
  
  ## Option 4.
  
  Has all the same characteristics as `Option 3.` but it is h265 so results in smaller files. When running ffmpeg, it will give you a warning `x265 [warning]: Support for interlaced video is experimental`
  
  I have found the experiment to be very successful, the VMAF (below) suggests the content is visually identical.
  
  ```
  ffmpeg.exe -i "my input video.avi" -vf format=yuv420p,yadif=mode=send_field
    -c:v libx265 -crf 23 -preset veryslow 
    -c:a aac -b:a 128k
    "my output video.mp4"
  
  ```
  
  Results in a progressive file for 50 frames per second from yadif 2x
  
  ```
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '01 nov 81 084 yadif x2 x265 crf23.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf59.16.100
    Duration: 00:00:13.52, start: 0.000000, bitrate: 3806 kb/s
    Stream #0:0[0x1](und): Video: hevc (Rext) (hev1 / 0x31766568), yuv420p(tv, progressive), 720x576, 3667 kb/s, 50 fps, 50 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  
  ```
  
  ## Objective quality analysis of output
  
  Compare how visually lossy your chosen `-crf` number was:
  
  ```
  ffmpeg -i "my output video.mp4" -i "my input video.avi" -lavfi libvmaf=log_path=output.xml -f null -
  
  ```
  
  I got around 97-96% with my 720x576. However I read that `-lavfi` thing does its best work at 1080p. <https://github.com/Netflix/vmaf/blob/master/resource/doc/faq.md>
  
  So scaling both videos to get a true value from `Option 1.` and `Option 2.` never got above 88.
  
  ```
  ffmpeg.exe -i "my output video.mp4" -i "my input video.avi" -filter_complex "[0:v]yadif=1:0:0,scale=1920x1080:flags=bicubic[main];[1:v]yadif=1:0:0,scale=1920x1080:flags=bicubic[ref];[main][ref]libvmaf" -f null -
  
  ```
  
  `yadif=1:0:0` means to go to 50fps <https://ffmpeg.org/ffmpeg-filters.html#yadif-1>
  
  For `Option 3.` and `Option 4.` the yadif filter isn't required.
  
  ```
  ffmpeg.exe -i "my output video.mp4" -i "my input video.avi" -filter_complex "[0:v]scale=1920x1080:flags=bicubic[main];[1:v]scale=1920x1080:flags=bicubic[ref];[main][ref]libvmaf" -f null -
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2021-07-29. Score: 1
  
  This seems to do what you want. `il` moves the odd lines to the top of the frame, and even lines to the bottom. Then `split` just creates 2 copies of this. We then `crop` both copies, to only include the top or the bottom. Finally, `framepack` will alternate frames from those two streams.
  
  ```
  ffmpeg -i input.mkv -c:v libx265 -filter_complex '[0:v]il=l=d:c=d,split[t0][b0];[t0]crop=720:240:0:0[t1];[b0]crop=720:240:0:240[b1];[t1][b1]framepack=frameseq' output.mkv
  
  ```
  
  But usually `yadif` can fix messed up videos like that, unless they also did something else to it to mess up the pattern too much. And if that's the case, this won't fix it either.
  
  > **Comments:**
  > **username_0**: It works inasmuch as the resulting video does have alternating frames that only contain odd and even fields. Judder is visible between frames, so it's clear that it worked.    So far so good.    Any way how to mark that these are actually fields in an interlaced video rather than a progressive video at twice the speed? I copied the _incomplete_ file in progress into another to watch the result and unless there is something meant to be written to the end of file, VLC doesn't seem to recognize the video for what it should be.  
  > **username_3**: I think that's a codec option. `-x265-params interlaced=1` or 2.  
  > **username_0**: I found it's -x265-params interlace=tff or bff, while it's -x264-params interlaced=1 or 2. I assume it works, but neither plays correctly. Both are shown at 640x240 at 50 fps with judder visible. I wonder if it's a video player problem now, but I'm using VLC, so it doesn't seem like it should be an issue.  
  > **username_0**: I tinkered a bit with it. It seems that field order is reversed, bottom field is first, which means I changed the command to this: ffmpeg ... -filter_complex '[0:v]il=l=d:c=d,split[t0][b0];...[b1][t1]framepack=frameseq' -x265-params interlace=tff ... When I used your command (where it was [t1][b1] and I changed the order), the video was extremely juddery in vertical motion, this judder is gone now.  
  
  ---
  
  