Need some help, Adv. Movie Player modification (framestep)

Just starting out? Need help? Post your questions and find answers here.
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Need some help, Adv. Movie Player modification (framestep)

Post by Zach »

Before I try to dive head-first into the DirectShow wrapper v1.3 by Inc. I thought I would try and modify the advanced movie player example (it has a window with buttons, etc) to try and produce a Framestepping function, using the MovieSeek command.

However my attempts have been less than fruitful and I am hoping it can be done, and that I just don't know the proper way to attempt it..

I need a framestepping command that can step forwards or backwards, by exactly 1 frame. If the movie is loaded but not playing, if the movie is playing but not paused, if the movie if paused, or if the movie has been stopped mid-stream. Pretty much has to work under any contingency where the movie is actually loaded, be it playing or not..

If anyone can take a stab at this,I would really appreciate it.

I mangled my example file so bad I had to delete it and get a new one :oops:
Image
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

It doesn't have to be "gimme da codez" either.. If I could just get some hints on what to try and where to start looking :oops:
Image
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Need some help, Adv. Movie Player modification (framest

Post by Kuron »

Zach wrote:It doesn't have to be "gimme da codez" either..
Should I take pleasure in playing a large part in what has become a legendary thread?
Best wishes to the PB community. Thank you for the memories. ♥️
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

Clarify.

Anyway I'm just looking for an example, seems like people post those here all day long when others ask :|
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Need some help, Adv. Movie Player modification (framest

Post by RASHAD »

Hi Zach
It can be a start( Hope it is )
Tested PB 4.60 x86 Win 7 x64

Code: Select all

Global Frame,Intime,Ptime

If InitMovie() = 0
  MessageRequester("Error", "Can't initialize movie playback !", 0) 
  End
EndIf

MovieName$ = OpenFileRequester("Choose the movie to play", "", "Movie/Audio files|*.avi;*.mpg;*.asf;*.mp3;*.wav|All Files|*.*", 0)
If MovieName$
    LoadMovie(0, MovieName$)
  
    OpenWindow(0, 100, 150, MovieWidth(0), MovieHeight(0)+40, "PureBasic - Movie")
    ButtonGadget(0,10,MovieHeight(0)+10,50,20,"Back")
    ButtonGadget(1,70,MovieHeight(0)+10,50,20,"Pause")
    ButtonGadget(2,130,MovieHeight(0)+10,50,20,"Play")
    ButtonGadget(3,190,MovieHeight(0)+10,50,20,"Resume")
    ButtonGadget(4,250,MovieHeight(0)+10,50,20,"Forward")
    
    FLength = MovieLength(0)
    FPS = MovieInfo(0,0)
    SLength = FLength/FPS
    Debug SLength
      
Repeat
;     Ptime = ElapsedMilliseconds() - Intime
;     CFrame = Ptime/1000*FPS 
  Select WaitWindowEvent()
      
       Case #PB_Event_CloseWindow
           Quit = 1
       
      
      Case #PB_Event_Gadget
          Select EventGadget()
           Case 0
                If Run = 0
                    Ptime = ElapsedMilliseconds() - Intime                
                    CFrame = Ptime/1000*FPS
                    Run = 1
                EndIf 
                PauseMovie(0)                  
                MovieSeek(0, CFrame - 1)
                ResumeMovie(0)
                PauseMovie(0)
                CFrame - 1
                Debug CFrame    
           
;            Case 1
;                 Ptime = ElapsedMilliseconds() - Intime
;                 PauseMovie(0)
;                 CFrame = Ptime/1000*FPS
           
           Case 2
                Pflag = 1
                Intime = ElapsedMilliseconds()
                PlayMovie(0, WindowID(0))
           
;            Case 3
;                 ResumeMovie(0)
           
           Case 4
                If Pflag = 0
                  Intime = ElapsedMilliseconds()
                  PlayMovie(0, WindowID(0))
                  Pflag = 1
                EndIf
                If Run = 0
                  Ptime = ElapsedMilliseconds() - Intime                
                  CFrame = Ptime/1000*FPS
                  Run = 1
                EndIf

                PlayMovie(0, WindowID(0)) 
                PauseMovie(0)                             
                MovieSeek(0, CFrame + 1)
                ResumeMovie(0)
                PauseMovie(0)
                CFrame + 1
                Debug CFrame          
           
          EndSelect
  EndSelect
Until Quit = 1
EndIf 
Egypt my love
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

Thanks Rashad,

It is as I feared, the example has the same problem I've had, in that even though the debug output indicates it is stepping forward, the video window is not updating with the new frame image. And if I resume play, it will still not update from the new seek location :( I noticed you had some things commented out too, I guess I was supposed to figure out which ones to enabled and disable based on the functionality I wanted? Cause I noticed if I uncommented all of it then I got really weird behavior. But in any case I couldn't get things to work right.

I had success getting this to work using the Win32 AVIFILE Library but have never been able to make it work with PB's movie player commands :(

I'm afraid the only solution may be to tough it out with the older AVIFILE Library, or to try and learn to use Incs DirectShow wrapper commands.

Thank you for trying, I appreciate it.
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Need some help, Adv. Movie Player modification (framest

Post by RASHAD »

Zach
I updated the code a little bit while you was testing it :)
So please run it again
- Load the movie
- Start clicking Forward

It works here fine with me except I do not know if the movie step forward by a real
one frame
Test it again who knows
Egypt my love
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Need some help, Adv. Movie Player modification (framest

Post by MachineCode »

Zach wrote:I need a framestepping command that can step forwards or backwards, by exactly 1 frame.
It actually depends on the encoding of the video. The rendering of all frames are based on "keyframes", which may only exist every 25 real frames (for example). So, if you load a video and seek straight to frame 26, then it might not display because you haven't viewed frame 25 (a keyframe) first. Likewise, if you're looking at frame 50 (a keyframe) and step back 1 frame, it may not display because you need to seek back to frame 25 first (a keyframe) and then extrapolate forward another 24 frames, one by one, to view frame 49.

Some videos are encoded with keyframes for every frame, so you can step back and forward without the issues and extrapolation mentioned above.

Hope this helps!
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

Well, in this case I am viewing MKV files simply as a testing measure. I need to go find a bonafied AVI to test with, which is a fair point.
However using the AVIFile32 Library I didn't have to go to extraordinary steps to get proper framestepping. So I'm not sure what to make of the keyframe "issue".

Even setting up a button that goes ResumeMovie(0), PauseMovie(0) doesn't show any frame progress on the picture, which I think is wrong in this case.. It may just be PB's movie library and the way it was implemented.

I am going to test out RASHAD's updated example.
Image
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

Ahhhhhhh OK

I managed to find an AVI file on my system and the framestepping does appear to work.. Not sure why its being fussy about MKV files (which are either xvid or h264 encoded depending on what I choose).


But I will be using this application exclusively intended for Frameserved Avisynth files (which serves any format as AVI) so as long as I can verify it works with AVS scripts next, I think I will be ready to go...
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Need some help, Adv. Movie Player modification (framest

Post by RASHAD »

You are very fast mate
I was going to tell you that I tested it against AVI :)
If you still want to use the native I can look at the case of MKV
Egypt my love
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

No, that's OK. I was just testing against MKV because it was available and I have a shit ton of them :p (All my video files are stored in MKV)

I really only need to get Avisynth installed, and test against that. If it works with Avisynth scripts, then all will be good. But it will definitely have to work with Avisynth scripts, as the utility I am building is completely built around the Avisynth environment and some of the plugins users have developed for it.

I have been wanting to make a tool for a long time, as a more user-friendly alternative to YATTA. Performing Inverse Telecine operations on Anime content is notoriously difficult in some cases, and still not without issues in most. YATTA is great because it gives you complete control over which frames get matched for IVTC processing, which get ignored, and can do other things as well such as setup filtering a single frame or a range of frames, changing the IVTC match pattern of a range of frames, replacing a bad frame with a copy of a duplicate frame that comes before/after it in the stream etc.. And if course the key feature of YATTA is support of VFR decimation and generation of MKV timecodes files, so that you can play back the video properly, as it was intended to be seen.. Most Anime is VFR by nature and have a mix of 24FPS and 30FPS video in the same stream (MPEG pulldown flags helped perpetrate this abomination for decades) so its all a pain in the ass for those wanting clean animation with no jerky sections.

It's all just a GUI for automating the writing of an Avisynth script, but YATTA is not very user-intuitive and has advanced features some people don't understand (including me).. So I want to make an easier to use alternative, that will let you IVTC Anime from DVD sources and the resulting output will be a VFR (Variable Frame Rate) video file, with a timecodes file to sync proper playback, that you can wrap inside an MKV with audio, subtitles, etc..
Image
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

Ok. Well it definitely loads the Avisynth script. And if you press PLAY, it will play the file.

However if you hit Back or Forward the video stops and seems to reset to the first frame. If you hit forward after loading the video, it doesn't seem to advance the frames either.

Seems like the same problem I was having with MKVs... Perhaps if you fixed it to work with MKV's it would work w/Avisynth scripts?

Hrmmm :?


important note about Avisynth. Avisynth is a frame server, it loads a video of a given format (via plugins supporting that format) and will serve one frame at a time, in a linear order, as requested by a program. It should be an AVI formatted frame (as the name implies) that is being served.

I'm not sure what to do.... we've come so close to getting it to work :oops:
Image
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

Actually you know what... hold off on this for a while.

I grepped around my HDDs and found my old project where I had succeeded in using the AVIfile API to open and step through Avisynth scripts (At least I believe I succeeded), and it is showing the same problem where it works fine with AVI files, but not AVS scripts.

I am gonna see if I can fix it with any configuration settings.
Image
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Need some help, Adv. Movie Player modification (framest

Post by Zach »

Hrmm no idea what the deal is... clearly the example in this thread can load and play AVS/MKV files, it just can't for some reason frame step through them..

My older work won't display anything for some reason, but looking at debug tools it is clearly able to open it and grab info about it... maybe something to do with the DIB format I dunno..

I'm really stumped as to what the problem with either of them could be.. Avisynth works fine on my system otherwise :(
Image
Post Reply