VideoHelp Forum




+ Reply to Thread
Results 1 to 11 of 11
  1. Member
    Join Date
    Mar 2010
    Location
    Switzerland
    Search PM
    Hello,

    I'm still working on transcoding an avi containing a proprietary video stream to an avi containing a h264 one as described here https://forum.videohelp.com/threads/317505-How-to-transcode-proprietary-VWV1-video-to-h264.
    A new problem araised (actually the last for an end to end working solution), where a conversion that I can't modify is buggy and I've got to shorten the video that is being transcoded according to following formula:

    nb_frames_orginial = fps * nb_frames_converted / 50

    This formula tells us that the lower the fps are, the greater the effect of the bug will be. E.g. when a video has 4.16fps, the converted video will contain 12x times the original one. With 50fps everything works fine, but no camera in my setup is using this frame rate...

    My problem is that I can't figure out how many frames the video contains.

    The solution I've got that is currently working is to transcode the entire video. Mencoder will show the number of frames at the end of the process and I'll extract of the first part that I need.

    As gspot is able to show me the exact frame count, I'll figured that their must be a way to get a hold of this number and have a cleaner and more effective solution then what is being done now.

    Currently, I need a proprietary tool from VisioWave to make the firsrst (buggy) conversion, then a combination of AviSynth and Mencoder does the rest of the job. If I could avoid having to use more external programs it would be great

    Any ideas?

    Thanks, Philippe
    Quote Quote  
  2. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by p.w View Post
    I can't figure out how many frames the video contains.
    Open in VDub, File/File information.

    Or if you've got an AVS file that loads it, add
    info()
    to the script.

    Or AviCodec will show the number of frames, and other info, about a whole folder of AVI files at once.
    You can export that to a CSV data file.
    Quote Quote  
  3. Member
    Join Date
    Mar 2010
    Location
    Switzerland
    Search PM
    I should have mentioned that I have to do this programmatically. Gspot also shows the right info, but I need a library or a command line tool where I can parse the output to retrieve the number of frames in the video.
    I'd like to have this number to tell mencoder to only transcode the relevant part of the video by setting the frame flag.
    Currently I transcode the entire movie and get the relevant part afterwards (<--ugly)
    Quote Quote  
  4. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    If you're already using an Avisynth script, then Framecount(clip) will give you the number of frames.
    Plus, Avisynth can also be used programmatically via the API normally used for plugins.
    Quote Quote  
  5. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by p.w View Post
    I should have mentioned that I have to do this programmatically. Gspot also shows the right info, but I need a library or a command line tool where I can parse the output to retrieve the number of frames in the video.
    I'd like to have this number to tell mencoder to only transcode the relevant part of the video by setting the frame flag.
    Currently I transcode the entire movie and get the relevant part afterwards (<--ugly)
    You may be able to script the apps I mentioned.

    Also See http://avicodec.duby.info/ for the source code for Avicodec.

    Or with Avisynth you can use FrameCount() as Gavino mentioned, and WriteFile() to write it to a text file,
    and parse it from there into your app.
    http://avisynth.org/mediawiki/WriteFile

    Code:
    WriteFileStart("Framecount.txt", "Framecount()")
    Quote Quote  
  6. Originally Posted by p.w View Post
    A new problem araised (actually the last for an end to end working solution), where a conversion that I can't modify is buggy and I've got to shorten the video that is being transcoded according to following formula:

    nb_frames_orginial = fps * nb_frames_converted / 50

    This formula tells us that the lower the fps are, the greater the effect of the bug will be. E.g. when a video has 4.16fps, the converted video will contain 12x times the original one. With 50fps everything works fine, but no camera in my setup is using this frame rate...

    Currently, I need a proprietary tool from VisioWave to make the firsrst (buggy) conversion, then a combination of AviSynth and Mencoder does the rest of the job.
    Am I understanding this right - you're basically duplicating frames to make every video 50fps? If so, why not use one of Avisynth's functions like changeFPS or convertFPS to do it?

    Also, is it imperative that every output video be exactly 50fps?
    Quote Quote  
  7. Member
    Join Date
    Mar 2010
    Location
    Switzerland
    Search PM
    @Gavino & AlanHK
    Thanks, that should do the trick! I'm going to give it a try right away.

    Originally Posted by creamyhorror View Post
    Am I understanding this right - you're basically duplicating frames to make every video 50fps? If so, why not use one of Avisynth's functions like changeFPS or convertFPS to do it?

    Also, is it imperative that every output video be exactly 50fps?
    Nope, the first step of the transcoding process is to convert an asf container containing a VWV1 video stream using a proprietary VisioWave tool that removes authentication frames and does some other business as well. This transcoding step is buggy and produces a much longer output (according to posted formula) when the video has a lower framerate then 50fps.
    What I'm trying to do here, is figure out what the frame rate of the video is, as well as retrieving the total frame count to know how many frames I have to extract (counted from the beginning of the video) in order to compensate the bug that occurs in this first transcode step. I don't really like to do it this way around, as we compensate for a bug, but there is no support for the version of the SDK we have to use.

    There are several framerates that are being used as input; 4.26, 8.33, 12.5, 25 and 50. All have to be handled correctly. Currently only the 50fps ones work without a problem. The transcoded h264 streams should use the same frame rate as the input to keep the original information without making the file bigger then it needs to be.
    Quote Quote  
  8. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by p.w View Post
    What I'm trying to do here, is figure out what the frame rate of the video is, as well as retrieving the total frame count
    You can print that out using the same method as framecount, see Clip_properties
    Quote Quote  
  9. Member
    Join Date
    Mar 2010
    Location
    Switzerland
    Search PM
    Now I'm starting to feel a little thick... According to the first example in WriteFile, I've created following script
    Code:
    #define the file where the analysis output will be stored
    outTextFile = "video_analyze.txt"
    
    #open the video that will be analyzed
    DirectShowSource("asfcheck_allframes.avi", audio=false)
    
    #create variables to hold the information that we need
    nbFrames=Framecount()                     
    fps=Framerate()
    
    #write the values to file
    WriteFileStart(outTextFile, "nbFrames") 
    WriteFileEnd(outTextFile, "fps")
    How can I avoid having avisynth play the entire file and do a frame by frame analysis that I don't need when it obviously is able to get the fps and frame count right after having opened the file? (When I hit stop on the playing stream, the WriteFileEnd() is performed.
    I'm using WriteFileStart and End because otherwise the information is outputted for every single frame. (<-- probably not a godd way to do this...)
    There must be something I don't get here!?

    [edit] I've tried playing with the DirectShowSource parameters (framecount) to shorten the video, but this also modifies the frame count (not that surprising..).
    Now I'm trying to find a way to stop playback after having opened the stream. Is that the good way to proceed?
    Last edited by p.w; 8th Mar 2010 at 03:55.
    Quote Quote  
  10. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by p.w View Post
    How can I avoid having avisynth play the entire file and do a frame by frame analysis that I don't need when it obviously is able to get the fps and frame count right after having opened the file? (When I hit stop on the playing stream, the WriteFileEnd() is performed.
    I'm using WriteFileStart and End because otherwise the information is outputted for every single frame. (<-- probably not a godd way to do this...)
    Why not just "WriteFileStart"?
    Why make new variables for clip properties? Just print them directly.
    You need "append" after the first otherwise each write will overwrite the file.

    Code:
    #write the values to file
    WriteFileStart(outTextFile, "FrameCount") 
    WriteFileStart(outTextFile, "FrameRate",append = true)
    Or put them both on one line with a space between in one write:

    Code:
    WriteFileStart(outTextFile, "FrameCount",""" " " """, "FrameRate")
    I usually run my files via VirtualDub. That just stays on frame 0 until you click "play".

    Also AvsP, just open the AVS, press F5 to view the first frame, and your data is written.
    Quote Quote  
  11. Member
    Join Date
    Mar 2010
    Location
    Switzerland
    Search PM
    You are absolutely right, I'm now using
    Code:
    #define the file where the analysis output will be stored
    outTextFile = "video_analyze.txt"
    
    #open the video that will be analyzed
    DirectShowSource("convertedVwAvi.avi", audio=false)
    
    #write the values to file
    WriteFileStart(outTextFile, "FrameCount") 
    WriteFileStart(outTextFile, "FrameRate", append = true)
    On the .NET side I now use a plain ugly implementation to do this analysis. If someone has a better solution before I find one myself, please feel free to share

    Code:
    Process p = new Process();
    p.StartInfo = new ProcessStartInfo(@"C:\Program Files\Windows Media Player\mplayer2.exe", "/Play \"C:\\dev\\expic\\Wavelet2h264\\Wavelet2h264Tester\\bin\\Debug\\AnalyseAvi.avs\"");
    p.StartInfo.CreateNoWindow = true;
    p.Start();
    System.Threading.Thread.Sleep(10000);
    p.Kill();
    I'm starting the avisynth script this way, because it was the command line shown by processexplorer when doing a right click -> play on a avisynth script file. Then I give it some time (10s) to do what it has to do and kill it aftwerwards; as said, reaally ugly.

    Thanks a lot to all you gays (and gals?). What I've learned from these two threads helped me a great deal!!!
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!