7

I'm trying to figure out how to use yadif / yadif-2x with ffmpeg to convert 50i source material into 50p output that preserves the motion of all fifty fields per second. Right now, I am using the following command, which creates a frame-doubled version, essentially the same as 25p output.

ffmpeg -i input.m2t -f:v yadif=1 -c:v prores output.mov

Using yadif=0 makes a deinterlaced 25p file. Using yadif=1 makes a deinterlaced 50p file with doubled 25p frames. I need to make a deinterlaced file with 50 unique frames per second, and I'm pretty well certain this is possible. Is that what yadif(2x) is supposed to do?

phuclv
  • 26,555
  • 15
  • 113
  • 235
moot
  • 141
  • 1
  • 1
  • 8
  • 1
    Please show your complete ffmpeg console output. – llogan Jun 21 '13 at 21:55
  • Available here: http://pastebin.com/CqsD5D8L – moot Jun 21 '13 at 23:52
  • After a great deal of searching, I may have found another way to accomplish this conversion. I will attempt this method tomorrow and report results. http://hddv.net/showthread.php?2876-Format-conversion-%2850i-50p-24p-25p%29-tests – moot Jun 22 '13 at 08:21
  • `yadif=1` works for me: twice as many frames and each is different – mark4o Jun 22 '13 at 16:55
  • I tried that again today and unfortunately it definitely produces 50p output, but only doubled frames for me. I am using the MacPorts installation on MacOS X with mencoder_extras among others. – moot Jun 22 '13 at 21:24
  • 2
    Are you sure that your input is interlaced? You can use `ffmpeg -i input.m2t -filter:v idet -f null -` to analyze it for frames that appear to be top-frame-first interlaced, bottom-frame-first interlaced, or progressive. – mark4o Jun 24 '13 at 03:54
  • Looks like you solved your issue, so you can create and accept your own answer. – llogan Dec 15 '14 at 18:19
  • ya, I didn't notice right away that you editted the answer into the question, since I was just skimming. Would be best to move that to an answer. – Peter Cordes Jan 04 '15 at 08:16

4 Answers4

4

It turns out that the video I was attempting to double-deinterlace was actually 25p that was encoded into a 50i video file in order to conform to an older AVCHD standard. Apparently this is a common practice for tapeless cameras from the mid-late 2000s. So of course when I attempt to deinterlace I only end up with, at most, the original source 25 frames per second because there is no motion between the fields.

f:v yadif=1 does exactly what is described - it takes true interlaced 50i footage and turns it into astonishingly high-quality 50p output using a motion-weighted bob algorithm, just the same as the "yadif 2x" realtime filter does in VLC. The output is of nearly double the effective vertical resolution over frame-discarded deinterlace. It is now one of my favorite video filters because practically nothing else appears to offer this capability.

moot
  • 141
  • 1
  • 1
  • 8
3

I used this command:

ffmpeg -i source_50i.MTS -aspect 1920:1080 -vf yadif=1,scale=1920:1080 -c:v libx264 -preset fast -profile:v high -crf 23 -ac 2 -strict experimental -c:a aac -b:a 96k -movflags +faststart -y result_50p.mp4

and it worked fine!

I didn't check if the yadif method good or not good quality, but really created from 50i MTS to 50p mp4 from a camcorder source file. The source file was 19 MB and the result was 21MB.

I say Reinstate Monica
  • 25,487
  • 19
  • 95
  • 131
ecchphoto
  • 31
  • 1
  • I used this answer successfully to create a video out of a GoPro time lapse at 60fps, in hopes that others find it useful: `ffmpeg -i 'G%*.JPG' -r 60 -vf "scale=1920:ih*1920/iw, crop=1920:1080, yadif=1" -c:v libx264 -preset slow -crf 18 -c:a aac -b:a 192k -pix_fmt yuv420p output.mkv` – Graham P Heath Feb 12 '18 at 21:52
0

I think many don't understand that 29.97 only referred to how frequently the cathode ray tube returned to scan the same 'pixel'. It had been at the adjacent (above or below) 'pixel' only 1/60th of a second earlier.

Each raster scan was a 1/60th sec. exposure. The next scan was the next 1/60th. They were not held; they were sent out 60x per second as half-resolution rasters stretched vertically to fill the screen. Through alternating odd-line and even-line scans, the appearance of full resolution was achieved with only half the 'bandwidth'.

It was always 60 distinct rasters per second, never 30.

-1

Please understand-- 50i means 50 fields = 25 frames of 50 interleaved fields. You CANNOT get unique 50 frames. If at all possible, then these frames would have missing alternate lines in the video frame. So 25p is 50i top + 50i bottom combined. That's how it should be, and hopefully always will be. Else the result could be duplicated frames (terrible) as you have got.

Rajib
  • 3,056
  • 23
  • 26
  • 1
    This is wrong. Yadif can interpolate missing lines and create real 50fps video from 50i, if this is indeed real 50i video (no duplicated fields — i.e. 2 fields from one frame). – Display Name Aug 29 '14 at 10:41
  • @SargeBorsch Please provide the answer- I'll gladly delete mine. Thanks for the information. Unfortunately I cannot test because I have no access to interlaced video any more. – Rajib Aug 29 '14 at 12:02
  • I don't have time to search how to (properly) make it happen with ffmpeg — but it clearly has the effect in VLC player (while playing 60i video & having Yadif x2 enabled). looks like ffmpeg has a bug — it always duplicates frames, so I get either 120fps or 60fps and in either case I must drop every 2nd frame, which is kind of "hacky" and ffmpeg has no clear way of dropping every 2nd frame – Display Name Aug 29 '14 at 12:42
  • If you care to share a short interlaced clip I'll give it a shot. – Rajib Aug 30 '14 at 07:21
  • Currently I have only one such video which is not supposed for sharing, but I may shoot another one sooner or later (my DSLR camera has option of recording in 60i), and send example of both original (interlaced) video and processed one. – Display Name Aug 30 '14 at 07:36
  • @SargeBorsch you're looking for `-vf yadif=1` to produce output with one interpolated progressive frame per input FIELD. `-vf yadif=0` loses the extra temporal resolution of the interlaced input by outputting a progressive frame for every other interlaced field. This keeps the frame rate the same, as far as interlacing-unaware stuff is concerned. – Peter Cordes Jan 04 '15 at 08:12
  • @PeterCordes yes, as far as I can recall this is like this. Although in my case, ffmpeg did also double frames, resulting in 4x framerate, so I needed to drop every other frame after deinterlacing (because I was getting 120fps stream which is actually just 60fps with duplicates) – Display Name Jan 04 '15 at 11:08
  • I wonder if you got 120fps because of ffmpeg a lowest-common-multiple frame rate for a container like mp4, where it defaults to not supporting variable frame rate. e.g. with a variable-fps input from a phone camera, ffmpeg can make a 90k fps output file. With mkv as the output container format, ffmpeg doesn't actually feed duplicate frames to the video codec, so you get proper VFR. There may be an option to mux VFR mp4 output from ffmpeg, but IDK what it is. – Peter Cordes Jan 13 '15 at 13:00
  • For anyone needing to know, adding `-vsync vfr` will mux VFR MP4s. – Gyan Dec 23 '16 at 16:58