Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Feb 2004
Posts: 192
|
Is there any good way to IVTC h.264 video in FFmpeg?
There doesn't seem to be a subforum for FFmpeg here, so I don't know exactly where this question belongs.
Previously I've only ever encountered telecined video in the form of DVD MPEG-2 streams, and I've always used "forced film" in DGIndex on those with good results. Today I encountered telecined h.264 video, and DGIndex doesn't work with h.264 video files, so I tried DGAVCIndex, but "forced film" did nothing at all. I couldn't try DGIndexNV because I guess you need an Nvidia video card just to use it. Then I tried the suggestions from this thread... https://forum.doom9.org/showthread.php?t=172289 ... but the results were bad. The original interlaced frames were turned into frames that looked like a blend of two frames, giving it a sort of ghost image effect on those frames. Then I tried VirtualDub's built-in IVTC filter, and that worked good; it looked just as good to me as DGIndex's "forced film" does on telecined MPEG-2 videos. By using VirtualDub2 I can use that same IVTC filter and also be able to encode with h.264, unlike with the standard VirtualDub. That would be okay if I only had one file to encode, but I need to encode a bunch of them, and it will take a lot longer with VirtualDub. With FFmpeg I can use a batch file to encode them all unattended. |
![]() |
![]() |
![]() |
#2 | Link |
ffx264/ffhevc author
Join Date: May 2007
Location: /dev/video0
Posts: 1,809
|
__________________
TV: Samsung QE50Q60T AVR: Denon AVR-X1700H CD: Yamaha CD-S300 Tuner: TechniSat 143v3 BD: Samsung UBD-M8500 Speakers: Klipsch Reference Phono: Audio-Technica AT-LP120X Amp: Marantz PM6007 |
![]() |
![]() |
![]() |
#3 | Link | |
Registered User
Join Date: Feb 2004
Posts: 192
|
Quote:
Code:
-vf fieldmatch,yadif=deint=interlaced,decimate Code:
-vf fieldmatch,yadif=deint=interlaced,mpdecimate=max=-4:hi=1000:frac=1 -r 23.976 ![]() That's worse than just leaving it in its original telecined state. Like I said, VirtualDub's built-in IVTC filter worked great; every frame is a good frame, just like when you use DGIndex's "forced film" on a telecined MPEG-2 video. |
|
![]() |
![]() |
![]() |
#4 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,258
|
Quote:
Sometimes the source timestamps are not perfect and it can mess with various ffmpeg operations Try adding -vf fps=30000/1001 Code:
-vf fps=30000/1001 ,fieldmatch,yadif=deint=interlaced,decimate |
|
![]() |
![]() |
![]() |
#5 | Link | ||
Registered User
Join Date: Feb 2004
Posts: 192
|
Quote:
Quote:
![]() It's strange that FFmpeg doesn't seem to have a function to do it correctly while VirtualDub's IVTC filter, which is at the very least, 10 years old, has no problem with it. Last edited by MaximRecoil; 25th December 2022 at 05:10. |
||
![]() |
![]() |
![]() |
#7 | Link | |||
Registered User
Join Date: Feb 2004
Posts: 192
|
Quote:
Quote:
This is how I originally had it, which gave bad results: Code:
-vf "crop=1440:1080,scale=704x480:flags=lanczos,pad=720:480:8:0,setsar=sar=10/11,fieldmatch,yadif=deint=interlaced,decimate" Quote:
So this is solved, thanks. I guess I should have posted my script in the first place, but it never occurred to me that seemingly unrelated things like cropping and resizing could possibly make a difference. Last edited by MaximRecoil; 25th December 2022 at 13:40. |
|||
![]() |
![]() |
![]() |
#8 | Link |
Registered User
Join Date: May 2006
Posts: 3,969
|
What crosses my mind:
In the first case you cropped and resized the combed ("interlaced") frames before restoring these to progressive frames by fieldmatching, which is no good as I understand because it screws the field structure up. Last edited by Sharc; 25th December 2022 at 13:45. |
![]() |
![]() |
![]() |
#9 | Link |
Registered User
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,387
|
Yes, as you discovered, never scale interlaced video as if it was progressive!
You mix the lines together, generating those nasty blended frames and nothing is going to be able to help after that.
__________________
madVR options explained |
![]() |
![]() |
![]() |
#10 | Link | ||
Registered User
Join Date: Feb 2004
Posts: 192
|
Quote:
By the way, I was reading this site... https://ffmpeg.org/pipermail/ffmpeg-...ch/141105.html ... and it says: Quote:
I'm not even sure what the purpose of "yadif=deint=interlaced" is if you're encoding purely telecined material. Is it for when you have a mix of film-source and video-source material in the same video file? Either way, if it accomplishes anything with purely telecined material it isn't anything I can notice with these particular video files, so I can do without it. |
||
![]() |
![]() |
![]() |
#11 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,258
|
Quote:
You can have a 100% film source, but you can still have cadence breaks (e.g. post telecine edits, common with 90's and early 2000's North American TV series on DVD), which leave you with combed frames If you have 100%, 3:2 pure, 100% no cadence breaks, then you wouldn't need it IVTC post processing . e.g most modern Hollywood movies on DVD are actually 100% soft telecine, perfect cadence. But you mentioned hard telecine... and that can sometimes be "iffy" . Sometimes just knowing what the title, what content, and what era it was produced in can provide clues as to what it is. |
|
![]() |
![]() |
![]() |
#12 | Link |
Registered User
Join Date: Feb 2004
Posts: 192
|
I have several different old TV series on Blu-ray. Sometimes I watch them directly from the Blu-ray on my PC, just to see how they look in HD, but more often than not I want to watch them the way they were seen when they originally aired, i.e., on a standard-resolution 4:3 CRT TV. That's a problem with Blu-ray though, because it's inherently 16:9, so 4:3 content is inevitably pillar-boxed. If you watch it as-is on a 4:3 TV, you end up with both the pillar-boxing that's hard encoded into the video stream and letter-boxing from the TV, i.e., window-boxing. So I rip them with MakeMKV and re-encode them to DVD resolution, since that's enough resolution to max out the quality potential of an SD TV. Going higher (e.g., 960 x 720 or 1440 x 1080) would just be a waste of drive space.
In any case, this is a 1970s shot-on-film TV series, and it's the first one I've encountered on Blu-ray that was hard telecined. In every other case, the ripped files were 23.976 FPS progressive as-is. Like I mentioned before, I've never had to IVTC anything except for when re-encoding DVD rips, and I haven't done that in years, because I don't re-encode DVD rips anymore. I rip them with MakeMKV and remux them into an MPG (Mpeg-PS) container and my Blu-ray player can play them from a USB drive (which is nice for watching a TV series because you don't have to keep changing discs), and there's no difference in the way the telecining is handled compared to playing them directly from the DVD. I've encoded and watched several episodes now without Yadif in the script and they all look perfectly fine. Last edited by MaximRecoil; 27th December 2022 at 19:20. |
![]() |
![]() |
![]() |
#13 | Link |
Registered User
Join Date: Feb 2004
Posts: 192
|
I noticed that one of the episodes that I encoded both ways (with and without Yadif in the script) have the same file size, right down to the byte:
![]() So I did a binary file comparison: ![]() Then I did the same binary file comparison for several other episodes that I encoded both ways and they were also bit-for-bit identical in every case, so Yadif hasn't done anything to these files at all. Even though Yadif isn't doing anything so far, I wonder if having it in the script slows down the encoding speed. They seemed to encode faster when I removed Yadif from the script, but that could have been a coincidence because there are a lot of constantly changing variables with an in-use PC that can affect encoding speed. If it doesn't affect encoding speed when there are no stray combed frames for it to deal with, then I wouldn't mind leaving it in the script just in case it happens to be needed in one or more of the several dozen episodes I still have to encode. |
![]() |
![]() |
![]() |
#15 | Link | |
Registered User
Join Date: Feb 2004
Posts: 192
|
Quote:
|
|
![]() |
![]() |
![]() |
#18 | Link |
Registered User
Join Date: Feb 2004
Posts: 192
|
Would it be possible to inverse telecine, crop and resize, and then re-telecine in the same script? I know I can't just leave the original telecining in there and resize it because I'll get those ugly blended frames.
I watch these old TV shows on a Blu-ray player from a USB drive, connected to a standard resolution (15 kHz / 480i) CRT TV, so when I play a progressive (23.976 FPS) video, the Blu-ray player has to convert it to 480i on the fly. It produces prominent interlacing artifacts when doing that, particularly noticeable on straight edges that are slanted, and also there are frequent moire and strobing effects that you can see in certain clothing, window blinds, etc. On the other hand, when I play video that's already telecined, such as an untouched DVD rip of a film-source TV show, interlacing artifacts are barely noticeable. I can't find much information about it online (probably because most people are only trying to get rid of telecining, not add it), other than this: https://ffmpeg.org/ffmpeg-filters.html#telecine If it's possible to do what I want, how would I incorporate it into the following script (I just want it to end up properly telecined like it started out as, but at 640x480 instead of pillar-boxed 1920x1080)? Code:
ffmpeg -i input.mkv -vf "fieldmatch,yadif=deint=interlaced,decimate,crop=1440:1080,scale=640x480:flags=lanczos" -c:v libx264 -crf 18 -c:a copy output.mp4 Last edited by MaximRecoil; 15th January 2023 at 04:46. |
![]() |
![]() |
![]() |
#19 | Link | |
Registered User
Join Date: May 2006
Posts: 3,969
|
Quote:
Code:
ffmpeg -i input.mkv -vf "fieldmatch,yadif=deint=interlaced,decimate,crop=1440:1080,scale=640x480:flags=lanczos,telecine" -c:v libx264 -crf 18 -c:a copy output.mp4 Code:
ffmpeg -i input mkv -vf crop=1440:1080,setfield=tff,setdar=4/3 -c:v libx264 -flags +ilme+ildct -crf 18 -c:a copy output.mp4 Last edited by Sharc; 15th January 2023 at 10:13. |
|
![]() |
![]() |
![]() |
#20 | Link | ||
Registered User
Join Date: Feb 2004
Posts: 192
|
Thanks. I don't need to specify any parameters for the telecine filter?
Quote:
Quote:
Last edited by MaximRecoil; 15th January 2023 at 16:11. |
||
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|