detelecine partial title

Archive of historical feature requests.
Please use the GitHub link above to report issues.
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Post Reply
sdm
Bright Spark User
Posts: 194
Joined: Mon Feb 19, 2007 4:53 pm

detelecine partial title

Post by sdm »

I searched and couldn't find this requested before or in the plans. Please forgive me if I missed it.

Sopranos Season 5 has the first chapter (intro) hard telecined to 29.97fps.
The bulk of each episode is 23.98fps with 2:3 pulldown flags.
The credits seem to be fully interlaced at 29.97fps

Seasons 1 - 4 have the intro chapter and the bulk as 23.98 with 2:3 pulldown. I encoded them without problem and let the credits be encoded without de-interlace and dropping the frame rate to 23.98 fps.

What I am requesting is, when the detelecine filter is fully implemented to output 23.98 fps, I would like to be able to specify it only be used on a certain chapter, or up to a certain frame.

Any chance? I know it seems like a challenge, and may not be used by many people.

I do have a work around solution to my problem, but it involves another program and I end up without chapters.

Thanks,
--sdm.
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

There is no need...when pullup works correctly, discarding duped frames, it works just as well on mixed-content.

I've considered applying it to only part of a title, but that will require a full pre-scan of the entire video, which will take a long time, and is something eddyg has said he isn't considering as strongly anymore.
sdm
Bright Spark User
Posts: 194
Joined: Mon Feb 19, 2007 4:53 pm

Post by sdm »

Great!

So Handbrake's detelecine filter will just leave the progressive film stuff untouched?

Is the discarding of duped frames something in active development, and we may see in an upcoming release?
I have the latest SVN, but can't select de-telecine on these titles (no matter what framerate option I choose)

Thanks for your help as always.
--sdm.
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

Last week I posted sample code in the dev forum, that, while not perfect, does a better job at pullup than what's in the svn...I was hoping some people would test it out and give me some feedback.

The silence has been truly deafening.
sdm
Bright Spark User
Posts: 194
Joined: Mon Feb 19, 2007 4:53 pm

Post by sdm »

hmmm. I think you are referring to the ""Same as source" FPS Improvements"?

I'd love to test it, but I'm not familiar with how to add your patch. And forgive me, but I suspect learning it may require more time than I have right now.

Unless its easy?

Thanks,
--sdm.
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

Yeah, that's the one.

Save the diff to your hard drive.

To apply any patch, cd to the directory where you store the latest source code and run:

patch -p0 < /path/to/patchfile.diff

Then build.
-x-
Posts: 4
Joined: Mon Sep 17, 2007 12:18 am

Which one is the diff?

Post by -x- »

I would really love to test this as I have so many dvd's with this issue. Where can I find the patch? I looked for a diff file in the dev forum, but could not locate it.

I can not wait until this is applied to an official release.
Last edited by -x- on Mon Sep 17, 2007 12:35 am, edited 1 time in total.
hawkman
Veteran User
Posts: 609
Joined: Sat Feb 17, 2007 9:46 pm

Post by hawkman »

-x-: Check the indicated topic, and there are diffs contained in the posts themselves. You'll need to make sure you get the latest ones, so I think reading the topic through is a must. :)
sdm
Bright Spark User
Posts: 194
Joined: Mon Feb 19, 2007 4:53 pm

Post by sdm »

I've copied and pasted the jbrjake's last patch into TextEdit in plaintext, wrap to window mode and saved in the file with a new copy of the SVN and ran "patch -p0 < /Users/sheldon/HB-dev/patchfile.diff" in the terminal. Results below.
Can anyone help?

Thanks
--sdm.

Last login: Sun Sep 16 20:36:40 on ttyp1
Welcome to Darwin!
Sheldon-McLeans-Mac-Mini:~/HB-dev sheldon$ patch -p0 < /Users/sheldon/HB-dev/patchfile.diff
patching file libhb/detelecine.c
Hunk #1 FAILED at 953.
Hunk #3 succeeded at 998 with fuzz 2.
Hunk #4 FAILED at 1006.
Hunk #5 succeeded at 1045 with fuzz 2.
2 out of 5 hunks FAILED -- saving rejects to file libhb/detelecine.c.rej
patching file libhb/muxmp4.c
patching file libhb/encavcodec.c
patching file libhb/render.c
Hunk #2 succeeded at 187 with fuzz 2.
Hunk #5 FAILED at 300.
1 out of 5 hunks FAILED -- saving rejects to file libhb/render.c.rej
patching file libhb/internal.h
patch unexpectedly ends in middle of line
Sheldon-McLeans-Mac-Mini:~/HB-dev sheldon$
hawkman
Veteran User
Posts: 609
Joined: Sat Feb 17, 2007 9:46 pm

Post by hawkman »

Looks like things must have changed significantly in svn since the revision that patch is against. I'm slightly surprised, but hey.

"patch unexpectedly ends in middle of line" on the last part generally means that the final line is missing a line break at the end - no big deal.

"fuzz" is again not usually a problem, it means things have changed a bit but the right place should have been found.

As for the hunks that failed - that means something's changed to the point that the appropriate place can't be found.

There are two options here. Probably easiest to revert this patch (run the same command, and answer yes when it asks you if you want to revert), then revert to revision 964 in your checkout, then apply this patch; theoretically, it should apply cleanly, as that's the revision it was diffed against.

You could also try to apply the failed hunks manually - in your case, this is what appeared to fail:

Code: Select all

Index: libhb/detelecine.c
===================================================================
--- libhb/detelecine.c	(revision 964)
+++ libhb/detelecine.c	(working copy)
@@ -953,6 +953,17 @@
     {
         parity = 0;
     }
+    if ( ( buf_in->flags & PIC_FLAG_PROGRESSIVE_FRAME) )
+    {
+        /* I don't know why this is necessary. I
+           originally added it because I thought
+           that's what libmpcodec's IMGFIELD_ORDERED
+           flag meant, but it isn't...
+           Still, if you remove it, frames 
+           won't be discarded properly. ?!        */
+        parity = 0;
+    }
+    
 	pullup_submit_field( ctx, buf, parity );
 	pullup_submit_field( ctx, buf, parity^1 );
     if( buf_in->flags & PIC_FLAG_REPEAT_FIRST_FIELD )
@@ -995,19 +1006,19 @@
 
 			if( !(buf_in->flags & PIC_FLAG_REPEAT_FIRST_FIELD) )
             {
-                goto output_frame;
+                goto discard_frame;
             }
 			
             frame = pullup_get_frame( ctx );
 			
             if( !frame ) 
             {
-                goto output_frame;
+                goto discard_frame;
             }
 			if( frame->length < 2 ) 
             {
 				pullup_release_frame( frame );
-                goto output_frame;
+                goto discard_frame;
 			}
 		}
     }
Index: libhb/render.c
===================================================================
--- libhb/render.c	(revision 964)
+++ libhb/render.c	(working copy)
@@ -267,6 +300,9 @@
         
         buf_tmp_in = buf_render;
     }  
+    
+    /* Pass that the frame might be telecined to the video encoder. */
+    buf_render->ivtc = in->ivtc;
 
     /* Set output to render buffer */
     (*buf_out) = buf_render;
The + marks are indications that these lines need to be added (without the inclusion of those marks). - marks mean removal of the line indicated. Open up the relevant files (indicated by Index:) and search for the areas that are to be patched (probably easiest to search for terms in the actual code, not work by line numbers). Then make the alterations indicated. This is a bit of a pain, however. :)
sdm
Bright Spark User
Posts: 194
Joined: Mon Feb 19, 2007 4:53 pm

Post by sdm »

Thanks Hawkman.

I got the patch working in a recent SVN - it turns out there were some line breaks where there should have been none.

My main goal here is to used HandBrake on dvd titles containing both hard telecine and soft telecine (ie progressive with 2:3 pulldown).

I tried using mp4 container, ffmpeg encoder and chose 29.97 fps as jbrjake recommends in the other thread.
However, the de-telecine filter is unavailable. (possible due to what Dynaflash mentioned "MacGui has a sanity check in it that won't let you choose detelecine on mostly progressive content").
So I'm not sure what direction to head now. I don't know if jbrjake's patch includes dynaflash's sanity check removal.

Should I try to build using SVN 964?

Thanks for everyones help.
--sdm.
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

sdm wrote:However, the de-telecine filter is unavailable. (possible due to what Dynaflash mentioned "MacGui has a sanity check in it that won't let you choose detelecine on mostly progressive content").
So I'm not sure what direction to head now. I don't know if jbrjake's patch includes dynaflash's sanity check removal.
No, it doesn't include dynaflash's bit...not sure why that's needed. The bit of code that disables the detelecine box should only run when the fps is at "same as source" or "23.976" not 29.97....

I guess go and apply dynaflash's patch from that other thread to block that bit out.
dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Post by dynaflash »

I misunderstood jbrjake when he asked us to try out his patch, I thought he wanted us to try it on all content, so I removed that sanity check in the macgui. After the fact, jbrjake "un-confused" me.

Sorry for any confusion I may have caused.
Post Reply