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. |
25th August 2012, 19:02 | #1 | Link |
Registered User
Join Date: Nov 2005
Posts: 583
|
Repeated frame removal - 1 in every 23 frames
Greetings.
This one is strange: the BD appears to have been encoded with one repeated frame inserted for every 23 frames, resulting in very jerky motion. Frame rate is 23.976 progressive. How can one remove the repeated frame, ideally without "re-encoding", or perhaps even in real time playback? And what to do with the audio and subtitles? The BD is Zang Ao Duo Ji, a Japanese/Chinese animation. Many thanks and best regards. Sample Sample Last edited by mariner; 25th August 2012 at 19:09. |
28th August 2012, 12:50 | #3 | Link | |
Registered User
Join Date: Nov 2005
Posts: 583
|
Quote:
A few questions: 1. Does it start from frame 1? Or does it identify the repeated frame? 2. What frame rate do you suggest to use for reencoding the decimated video stream? Same as the original, 23.976? 3. What software should I use to speed up/resample the audio stream to match the new video stream? Do I do 24/23 speed up? Can it be done keeping the same pitch? 4. Same for subtitle? 5. Is this due to some obscure anime cadence confusing the splitter? Or is this a genuine error in the encoding encoding? Many thanks and best regards. |
|
28th August 2012, 14:05 | #4 | Link | |||||
Guest
Join Date: Jan 2002
Posts: 21,901
|
Quote:
Quote:
Quote:
vid=dgsource("mastiff.dgi") aud=nicac3source("mastiff PID 1101 3_2ch 48KHz 448Kbps DELAY -25ms.ac3",2).delayaudio(-0.025) audiodub(vid,aud) tdecimate(cycle=23,cycleR=1) assumefps(23.976,sync_audio=true) That will not correct the pitch but maybe it is good enough. If you want to correct the pitch, look at TimeStretch(), although I could not make it work for changing the decimated 22.934 to 23.976. Maybe an audio expert will chime in on that. Alternatively, you can use an external application like Audacity to change the audio rate without changing the pitch. Quote:
Quote:
|
|||||
3rd September 2012, 12:51 | #5 | Link |
Registered User
Join Date: Nov 2005
Posts: 583
|
Thanks again, neuron2.
Got the following error message: Code:
Scripte error: there is no function name "dgsource" Code:
vid=dgsource("mastiff.dgi") aud=nicac3source("mastiff PID 1101 3_2ch 48KHz 448Kbps DELAY -25ms.ac3",2).delayaudio(-0.025) audiodub(vid,aud) tdecimate(cycle=23,cycleR=1) assumefps(23.976,sync_audio=true) |
13th September 2012, 12:31 | #7 | Link |
Registered User
Join Date: Nov 2005
Posts: 583
|
Thanks neuron2.
1. Copied the contents of DGDecNV2042 to the plugins folder of Avisynth and got the following error message: Code:
DGSource : Cannot open index file! 3. Should the cycle parameter in tdecimate be set to 24 instead of 23? Many thanks and best regards. Last edited by mariner; 13th September 2012 at 12:54. |
13th September 2012, 13:39 | #8 | Link | |||
Guest
Join Date: Jan 2002
Posts: 21,901
|
Quote:
Quote:
Quote:
|
|||
13th September 2012, 22:11 | #10 | Link | ||
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
negatives: possible interpoloation artifacts (edge morphing). recommended a frame accurate source filter for this type of work (otherwise frames get mixed up and interpolated incorrectedly) You can encoded to an I-frame lossless intermedate with directshowsource if you have to Quote:
e.g these are duplicates: 5,6 29,30 53,54 (This code was from gavino's help on another project) Code:
sup = MSuper() bv = MAnalyse(sup, isb=true, delta=2) fv = MAnalyse(sup, isb=false, delta=2) interpolated = MFlowInter(sup, bv, fv, time=50.0, ml=100).DuplicateFrame(0) replace = interpolated.SelectEvery(24, 6) # replacement frames DeleteEvery(24, 6) # delete bad frames InterleaveEvery(replace, 24, 6) # replace deleted frames If the duplicates are not in a fixed pattern, you can use filldrops() or related functions (there are a few modified ones floating around for mvtools2), which calculate based on dupe detection (you can adjust the threshold value and check it with the debug mode) |
||
16th September 2012, 08:49 | #11 | Link |
Registered User
Join Date: Nov 2005
Posts: 583
|
Thanks neuron2. Few more questions:
Video 1. The pattern seems to be 23 distinct frames followoed by 1 repeated frame, so tdecimate(cycle=24,cycleR=1)? 2. What parameters do you suggest for re-encoding the decimated video, for 22GB target file size to fit in a BD-25? Here's the mediainfo: Code:
General ID : 0 (0x0) Complete name : D:\BDMV\STREAM\00007.m2ts Format : BDAV Format/Info : Blu-ray Video File size : 19.5 GiB Duration : 1h 34mn Overall bit rate mode : Variable Overall bit rate : 29.5 Mbps Maximum Overall bit rate : 48.0 Mbps Video ID : 4113 (0x1011) Menu ID : 1 (0x1) Format : AVC Format/Info : Advanced Video Codec Format profile : High@L4.1 Format settings, CABAC : Yes Format settings, ReFrames : 3 frames Format settings, GOP : M=3, N=12 Codec ID : 27 Duration : 1h 34mn Bit rate mode : Variable Maximum bit rate : 35.0 Mbps Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate : 23.976 fps Standard : NTSC Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 3. It's not clear how the -25ms delay helps when the decimated clip is ~4% (4 minutes) shorter. Or is the audio sync issue dealt with by the sync_audio=true parameter? 4. The AC3 audio is 6 channels, but can't seem to get nicac3source to output more than 2 channels. Both aud=nicac3source("mastiff.ac3",6) and ("mastiff.ac3") result in error. 5. TimeStretch(tempo = 100*25.0/(24000.0/1001.0)) seems to work on the sample. Need to test with the full clip. 6. Need help with audio source filters that work on the m2ts clip instead of demuxed audio files. Not having much success with FFaudiosource and DirectShowSource. The clip has two 6 channel audio streams : 640kbps TrueHD/AC3 and 448kbps AC3. Code:
Audio #1 ID : 4352 (0x1100) Menu ID : 1 (0x1) Format : TrueHD / AC-3 Mode extension : CM (complete main) Format settings, Endianness : Big Muxing mode : Stream extension Codec ID : 131 Duration : 1h 30mn Bit rate mode : Variable / Constant Bit rate : Unknown / 640 Kbps Maximum bit rate : 4 947 Kbps / 640 Kbps Channel(s) : 6 channels Channel positions : Front: L C R, Side: L R, LFE Sampling rate : 48.0 KHz Bit depth : 16 bits Audio #2 ID : 4353 (0x1101) Menu ID : 1 (0x1) Format : AC-3 Format/Info : Audio Coding 3 Mode extension : CM (complete main) Format settings, Endianness : Big Codec ID : 129 Duration : 1h 30mn Bit rate mode : Constant Bit rate : 448 Kbps Channel(s) : 6 channels Channel positions : Front: L C R, Side: L R, LFE Sampling rate : 48.0 KHz Bit depth : 16 bits Compression mode : Lossy Stream size : 291 MiB (1%) |
16th September 2012, 13:56 | #12 | Link |
Guest
Join Date: Jan 2002
Posts: 21,901
|
Yes, those tdecimate values would be correct values for 23 frames followed by one duplicate.
Can't help with your encoding question, I rarely do such things. Audio delay affects the starting offset of the audio so it doesn't matter if frames are removed. Note that the first frame cannot be removed because it cannot be a duplicate. The tdecimate() by itself will not change the audio sync. That would only be an issue if you did an AssumeFPS() to get back to a standard frame rate. I suggest reposting your other audio questions in appropriate threads/forums. I don't know the answers to them. Last edited by Guest; 16th September 2012 at 13:59. |
16th September 2012, 17:53 | #13 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Did anyone realize that always 2 frames after the duplicate frame there is one frame missing? - It's a "A B C D D E,,G H" sequence. It almost seems like some form of IVTC has been performed, but the decimator has dropped out of phase, hence has removed good nearby frames instead of the IVTC-duplicates.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 16th September 2012 at 18:07. |
17th September 2012, 13:56 | #15 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
In the given sample it's not exactly obvious to see, but it can be tracked. In the very beginning there is 12fps animation. Stepping single frames, one can see that every 24 frames there is one instance with 3 frames of one motion state, followed by 1 frame of one motion state. In the long running dog sequence its hard to see in motion, but the missing frame can be tracked by the grass at the bottom, there's always a skip one frame after the dup. It would be more obvious in the end scene, scrolling mountains at 24fps - but the scene is too short to notice it easily.
In any case, just deleting the dup frame and forcing the 23fps to 24fps again will not result in fluid motion. (Well, whatever "fluid" may mean in case of animation.) After deleting the dups, you still have the skips ... What would be needed to be done is: shift the frame right of the dup to the left, and place something interpolated into its position - either a simple blending, or a motion interpolation. Motion interpolation is somewhat problemtic with animation, though.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
18th September 2012, 13:38 | #16 | Link |
Registered User
Join Date: Nov 2005
Posts: 583
|
Greetings Keiyakusha, poisondeathray and Didée.
Many thanks for all the suggestions, and in particular Didée's brilliant observation. Didée is right, of course. The attached screen cap of 8 frame running dog sequence shows clearly the repeated (blue) and removed (red) frames. Re-encoding seems to be in order. Detailed instructions appreciated. Many thanks and best regards. |
19th September 2012, 23:12 | #17 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Code:
# LoadPlugin("MVTools2.dll") dgsource("mastiff.dgi") o = last o4 = o.pointresize(width+16,height+16,-4,-4,width+16,height+16) o8 = o.pointresize(width+16,height+16,-8,-8,width+16,height+16) o12 = o.pointresize(width+16,height+16,-12,-12,width+16,height+16) d2p = mt_lutxy(o,o.selectevery(1,-1),"x y - abs 128 *").greyscale() dup = mt_lutf(d2p,d2p,mode="avg",yexpr="x").mt_lut("x 2 < 255 0 ?") skip = dup.selectevery(1,-1) sup = o.msuper(pel=1) bv = sup.manalyse(isb=true, blksize=16,overlap=0,search=5,searchparam=6,DCT=5) fv = sup.manalyse(isb=false,blksize=16,overlap=0,search=5,searchparam=6,DCT=5) inter = o.mblockfps(sup,bv,fv,num=0,mode=3).selectodd() sup4 = o4.msuper(pel=1) bv4 = sup4.manalyse(isb=true, blksize=16,overlap=0,search=5,searchparam=6,DCT=5) fv4 = sup4.manalyse(isb=false,blksize=16,overlap=0,search=5,searchparam=6,DCT=5) inter4 = o4.mblockfps(sup4,bv4,fv4,num=0,mode=3).selectodd().crop(4,4,-12,-12,true) sup8 = o8.msuper(pel=1) bv8 = sup8.manalyse(isb=true, blksize=16,overlap=0,search=5,searchparam=6,DCT=5) fv8 = sup8.manalyse(isb=false,blksize=16,overlap=0,search=5,searchparam=6,DCT=5) inter8 = o8.mblockfps(sup8,bv8,fv8,num=0,mode=3).selectodd().crop(8,8,-8,-8,true) sup12 = o12.msuper(pel=1) bv12 = sup12.manalyse(isb=true, blksize=16,overlap=0,search=5,searchparam=6,DCT=5) fv12 = sup12.manalyse(isb=false,blksize=16,overlap=0,search=5,searchparam=6,DCT=5) inter12 = o12.mblockfps(sup12,bv12,fv12,num=0,mode=3).selectodd().crop(12,12,-4,-4,true) inter = merge(merge(inter12,inter8),merge(inter4,inter)) conditionalfilter(dup,o,o.selectevery(1,1),"averageluma","<","2") conditionalfilter(skip,last,inter,"averageluma","<","2") return(last) If you watch the single frames, you'll certainly find that there are errors in the motion-interpolated frames. In particular in the running dog scene, motioninterpolation is not very successful. In the mountains scene, OTOH, the interpolation is fairly okay. However, do not only judge by the quality of single frames. Make some shorter encoding tests, and watch the result in motion. Lots of errors that seem obvious in a freeze frame, may go by almost un-noticed during normal playback. Important is that there is something that represents the expected motion state. _____ Technical note: The script implements averaging of 4 off-setted MBlockFPS. That's not fast (but no drama here because it is used only for 1 frame out of 24 anyway), but avoids the swirling-artifacts of MFlowFPS, and reduces the blocking of normal MBlockFPS. (IF it occurs, it's split up into micro-blocking, with the result appearing more "blurry", rather than "blocky".)
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
21st September 2012, 09:58 | #18 | Link |
Registered User
Join Date: Nov 2005
Posts: 583
|
Thanks for the script, Didée.
1. Can you suggest another source filter (must it be frame accurate?) for my non NV system? 2. Can you help with getting audio to work? This script result in error. Code:
a=FFaudioSource("mastiff.m2ts",track=2) Edit: 1. Audio track 2 playable by enabling raw codec in FFdshow audio decoder. 2. Audio track 1 not playable, error message: "FFaudioSource : audio stream not seekable." Last edited by mariner; 22nd September 2012 at 09:47. |
|
|