[RESOLVED] Any way to select specific frame types (ipb) only? (mostly AVC)
[RESOLVED] Any way to select specific frame types (ipb) only? (mostly AVC)
I'm looking for an easy way to select only certain frame types, i/p/b, in an avisynth script.
I know for FFMS2, there's "FFPICT_TYPE" to help get I frames only, for example.
I'd prefer to use DGdecodeNV.
Is there any way to do this with DGdecodeNV?
Maybe some sorcerer knows a script to read out of the DGI file for frame types.
Although, it looks like frame type values are different depending on codec used. MPEG != AVC values for frame types in DGI file, so maybe some extra footwork is required.
So far, I've been opening the DGI file in a text editor and searching for frame types.
"Find all" for " 6 " (with spaces) for B frames, for exmaple.
For faster usage, I just skip through frames in AvsPmod with "Show=true" and hope a B frame is nearby (although, sometimes some scenes don't include B frames and are all just I/P frames).
Any pointers/shortcuts would be appreciated.
I know for FFMS2, there's "FFPICT_TYPE" to help get I frames only, for example.
I'd prefer to use DGdecodeNV.
Is there any way to do this with DGdecodeNV?
Maybe some sorcerer knows a script to read out of the DGI file for frame types.
Although, it looks like frame type values are different depending on codec used. MPEG != AVC values for frame types in DGI file, so maybe some extra footwork is required.
So far, I've been opening the DGI file in a text editor and searching for frame types.
"Find all" for " 6 " (with spaces) for B frames, for exmaple.
For faster usage, I just skip through frames in AvsPmod with "Show=true" and hope a B frame is nearby (although, sometimes some scenes don't include B frames and are all just I/P frames).
Any pointers/shortcuts would be appreciated.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
What do you mean by "get the frames"? Are you just trying to determine which frames are I frames? Are you trying to create a stream with only I frames? What would be your ideal output and how would you use it?
E.g., you can open the file in DGIndexNV and single step watching the Info dialog (if you step from the beginning then the frame number is the Coded # minus 1). But knowing exactly what you want and need, I may be able to offer you more, including an enhancement to the code.
E.g., you can open the file in DGIndexNV and single step watching the Info dialog (if you step from the beginning then the frame number is the Coded # minus 1). But knowing exactly what you want and need, I may be able to offer you more, including an enhancement to the code.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
I basically would like to see something like this:
"Are you trying to create a stream with only I frames?"
Essentially, yes. Of any selected frame type.
That way when I open the script in AvsPmod, and frame step from start to finish, I see only the selected i/p/b frames.
This would help with taking screenshots.
Selecting any frame type would help jumping to any random frame in AvsPmod while it returns only the selected frame types.
Useful for making wallpapers and comparing test encodes.
(i for most quality, other types for seeing how well it compressed, etc)
Code: Select all
SelectEvery(frame_type=b) #or i/p/b
Essentially, yes. Of any selected frame type.
That way when I open the script in AvsPmod, and frame step from start to finish, I see only the selected i/p/b frames.
This would help with taking screenshots.
Selecting any frame type would help jumping to any random frame in AvsPmod while it returns only the selected frame types.
Useful for making wallpapers and comparing test encodes.
(i for most quality, other types for seeing how well it compressed, etc)
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
Got it. Lemme think on it a while.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
Do you know about the DGSource(show=true) option? It will display the frame type.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
Yes, that's what I've been doing so far when not trying to refer to the DGI file.admin wrote:Do you know about the DGSource(show=true) option? It will display the frame type.
Largely relying on luck.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
How does luck enter? Maybe I still don't understand your needs.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
If I blindly run through the video in AvsPmod with show=true enabled, I have to keep scanning for b frames or other frame types I want for screenshots.admin wrote:How does luck enter? Maybe I still don't understand your needs.
There's this thread that uses FFMS2 to select frame types...
[link removed]
A case examples from that thread:
Code: Select all
import("C:\Program Files (x86)\AviSynth 2.5\plugins\avs\FFMS2.avsi")
FFmpegSource2("F:\1.avi")
ConvertToRGB32()
return ScriptClip("""chr(FFPICT_TYPE)=="I"
\ ? Last.ImageWriter("E:\thumbs\filename_prefix-",
\ start=current_frame, end=current_frame, type="png")
\ : Last""",
\ after_frame=true)
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
I have a test version for you that sets the FFPICT_TYPE environment variable. Do you want 32 or 64 bit?
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
32 would suffice. I rarely use 64 these days.admin wrote:I have a test version for you that sets the FFPICT_TYPE environment variable for AVC. Do you want 32 or 64 bit?
I tried looking at the source code for ffmpegsource and it looked to work around libav for getting video properties.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
It's in the binaries area called sparktank.rar. I supported all the video types. Let me know if it works and then I can slipstream it.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
Alright, it took a little bit to find clips.
For AVC and VC-1, it works perfectly!
^Giving me only screenshots of B frames in the VC-1 source.
^Giving me only screenshots of B frames in the AVC source.
Just trying to work out MPEG sourece, however.
For AVC and VC-1, it works perfectly!
Code: Select all
## VC1 source
LoadPlugin("D:\AVS\dgdecnv_test\DGDecodeNV.dll")
DGSource("G:\Clips\Inception\Inception-test.dgi", show=true)
ConvertToRGB32()
return ScriptClip("""(FFPICT_TYPE==3)
\ ? Last.ImageWriter("E:\Temp\Pics\Inception-3-",
\ start=current_frame, end=current_frame, type="png")
\ : Last""",
\ after_frame=true)
Code: Select all
##AVC source
LoadPlugin("D:\AVS\dgdecnv_test\DGDecodeNV.dll")
DGSource("D:\MakeMKV\DARK_KNIGHT_TRILOGY_BONUS_DISC\00064.dgi", show=true)
ConvertToRGB32()
return ScriptClip("""(FFPICT_TYPE==5)
\ ? Last.ImageWriter("E:\Temp\Pics\TDK-",
\ start=current_frame, end=current_frame, type="png")
\ : Last""",
\ after_frame=true)
Just trying to work out MPEG sourece, however.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
Don't worry, if it works for one it works for all. This is the first time I have set an Avisynth environment variable.
Be aware that there can be some ambiguity if you have soft pulldown that you are honoring. FFMS returns 'U' for that. I return the type of the base frame, i.e., the coded frame whose field is not pulled down in the displayed frame. So be careful with soft pulldown. You're unlikely to want to select such frames for your PNGs, but I thought it was worth mentioning it.
Thank you, sparktank, for your suggestion and your testing. I'll slipstream it tomorrow.
Be aware that there can be some ambiguity if you have soft pulldown that you are honoring. FFMS returns 'U' for that. I return the type of the base frame, i.e., the coded frame whose field is not pulled down in the displayed frame. So be careful with soft pulldown. You're unlikely to want to select such frames for your PNGs, but I thought it was worth mentioning it.
Thank you, sparktank, for your suggestion and your testing. I'll slipstream it tomorrow.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
Now I think I should use the character indicators 'I', 'P', and 'B' rather than the numbers, because the numbers are different for different video types. I'll do that before I slipstream it.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
Just checking on the off chance ... it won't break vapoursynth will it ?admin wrote:set an Avisynth environment variable
I really do like it here.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
I don't see why it would. You can test it for us.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
Awesome work!
Yeah, I thought about how it would work on DVD rips, so I'll definitely keep that in mind.
This will open up some new ways to look at things. I vaguely saw a script where you can return only I frames with scriptclip. It depended on FFMS2 largely, so I'll have to hammer it out to work for DGdecNV.
Thanks a bunch for this!
Yeah, I thought about how it would work on DVD rips, so I'll definitely keep that in mind.
This will open up some new ways to look at things. I vaguely saw a script where you can return only I frames with scriptclip. It depended on FFMS2 largely, so I'll have to hammer it out to work for DGdecNV.
Thanks a bunch for this!
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
I wonder if it should be renamed to "DGPIC_TYPE" instead of "FFPIC_TYPE" for sake of clarity, in case someone has ffms2 in their auto-load plugin directory.
And maybe update the document? Those with sorcery skills can eventually start showing their work on the interwebs for more things to do with this.
So far, I am loving this function so much.
Already have over 4K images to siphon through for candidate wallpapers.
And maybe update the document? Those with sorcery skills can eventually start showing their work on the interwebs for more things to do with this.
So far, I am loving this function so much.
Already have over 4K images to siphon through for candidate wallpapers.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
I doubt the name matters because people won't be using FFMS2 and DGDecodeNV together.
There is an explanation at the start of the DGSource() section of the manual. Did you miss it or are you referring to something else?
Glad you like it and thanks for the suggestion.
There is an explanation at the start of the DGSource() section of the manual. Did you miss it or are you referring to something else?
Glad you like it and thanks for the suggestion.
Re: Any way to select specific frame types (ipb) only? (mostly AVC)
I did miss it.
That seems to be it.
That seems to be it.