0

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.

3
  • I think all you need is to specify an output which is interlaced. ffmpeg will do the rest for you. Jul 9 at 17:59
  • 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.
    – toughluck
    Jul 10 at 17:30
  • 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. Jul 11 at 0:13
0

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.

4
  • 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.
    – toughluck
    Aug 2 at 22:26
  • I think that's a codec option. -x265-params interlaced=1 or 2.
    – stribika
    Aug 4 at 17:19
  • 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.
    – toughluck
    Aug 9 at 11:26
  • 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.
    – toughluck
    Aug 9 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.