VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or try DVDFab Passkey and copy Blu-ray and DVDs! :)
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. Member
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    I acquired a video (HuffYUV) from a tape, where a portion is damaged. I want to replace the bad video segment with the same segment from the acquisition of an undamaged tape that a friend will send to me.

    While waiting the arrival of the undamaged tape, I did some experiment on the existing clip, using VirtualDub to extract a sequence from the video (frames between n1 and n2), and using Avisynth + VirtualDub to insert the extracted sequence back in the original video (later this sequence to insert will become the new acquired video from the new tape).

    I have some problem:

    I extract with Virtual cut function, from frame n1 ( frame 27) to frame n2 (frame 1134).
    I use the options "Video -> Direct stream copy" and "Audio -> No audio" to save the sequence in a new avi.
    In the saved segment the last frame (frame 1107) is replaced with a blank frame.
    In addition VirtualDub reports "Selecting frames 27-1334 (1307 frames)" and not "... (1308 frames)".

    I wrote this avisynth script to delete exactely the same sequence from the original video and replace it with the previously saved avi:

    Code:
    # define first frame (n1) and last frame (n2) of bad sequence
    n1=27
    n2=1134
    
    video=AviSource("... original.avi")
    video_noaudio=video.killaudio()
    
    a=video_noaudio.Trim(0, n1-1)
    b=video_noaudio.Trim(n1, n2)	# to remove
    c=video_noaudio.Trim(n2+1, 0)
    d=AviSource ("... repare.avi")	# to insert
    video2=a+d+c
    
    # convert color space to YUY2
    # video2_yuy2=video2.ConvertToYUY2()
    
    audiodub(video2, video)
    I open the avisynth script with VirtualDub and save a new avi using the options "Video -> Full processing mode" and "Audio -> Direct stream copy", and compressing the video with HuffYUV.

    The resulting new avi contains 1 frame less than the original.
    In addition its size is much larger than the original (almost double the size).

    What am I doing wrong in this procedure to cause the mismatch in the number of frames?
    Why is the final file so much bigger? Is it because VirtuaDub RGB space color? (Even if trying to use YUY2 as the original file does not change the final file size)
    Quote Quote  
  2. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    instead of avisource try ffvidesource and ffaudiosource (ffms2.dll)

    Avisynth always frameserves uncompressed frames. The file size after you encode in the host app
    is always determined by what you choose there.
    Quote Quote  
  3. Why not extract using an AviSynth script? I've never used VDub for what you did and maybe its first frame isn't zero, as with AviSynth, but one. If you're extracting using AviSynth and use the line:

    Trim(27, 1334)

    You'll get 1308 frames. Maybe, if using VDub, you have to begin with 27, or end with 1335. I don't know and don't intend to test.

    Is it because VirtuaDub RGB space color?
    Yes, don't use Full Processing Mode. Why do you want YUY2? Is the source video YUY2 and not YV12? Won't your final colorspace be YV12?

    You can confirm or disprove by opening the cut video in VDub using this AviSynth script:

    AviSource("Video.avi")
    Info()


    It'll tell you the colorspace.
    Quote Quote  
  4. Originally Posted by lollo View Post
    The resulting new avi contains 1 frame less than the original.
    Check the lengths of b and d.
    Quote Quote  
  5. Member
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    First of all, many thanks to all of you for your help on this topic.

    @ davexnet

    try ffvidesource and ffaudiosource (ffms2.dll)
    When I use ffms2, if I rebuild the original video (a+b+c) the frame count in VirtualDub is wrong by more than 10 frames.
    If I use the new sequence (a+d+c) the software complains that the video format does not match.
    I will try some more experiment with ffms2.

    The file size after you encode is determined by what you choose
    I used the same compressor (HuffYUV) that I used during capture, and I expected a file size similar to the original video.
    I also understand that the input to HuffYUV during capture is the 4:2:0 YUY2 of my Hauppauge USB Live, while Virtualdub is working with the stream coming from AviSynth,
    so may be this is the reason of the different size. However, I wonder why the size is the double and not different by just a bit, may be I am doing something wrong.

    @ manono

    Why not extract using an AviSynth script?
    I have only 1 file to work with, so in order to do not write back the original file with
    video2=a+b+c
    I made a copy of it and modify the avs script in this way

    Code:
    a=video_noaudio.Trim(0, n1-1)
    b=video_noaudio.Trim(n1, n2)	# sequence to remove
    c=video_noaudio.Trim(n2+1, 0)
    d=AviSource("... copy of original.avi").killaudio().Trim(n1, n2)	# sequence to insert
    video2=a+d+c
    Excellent! When not using VirtualDub for the cut, the frames match! (I will double check the result)

    Yes, don't use Full Processing Mode
    I do not understand this. My goal is to save the repaired video as a "master" in lossless HuffYUV, so I have no other choice, until somebody will develop a "cut&join" video
    editor working in HuffYUV


    It'll tell you the colorspace
    Original colorspace is confirmed to be YuY2

    @jagabo

    Check the lengths of b and d.
    Good hint: as I said the number of frames are the same, but the last frame in d is blank.


    Finally I have the impression that using a mix of cut with VD and trim with AVD is not working, or I am not able to make it right.
    I will then use AVS only as suggested.

    Thanks again to you guys for your help!
    Quote Quote  
  6. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    I did a quick and dirty mod to your script, this seems to work

    # define first frame (n1) and last frame (n2) of bad sequence
    LoadCPlugin("I:\program files\Your_path\Lib\ffms2.dll")
    n1=27
    n2=1134
    Audio = FFAudioSource("I:\itemp\#i misc\Doctor Who 50th Trailer1 - Day Of The Doctor.avi", track=-1)
    video=FFVideoSource("I:\itemp\#i misc\Doctor Who 50th Trailer1 - Day Of The Doctor.avi", track=-1, seekmode=0)
    video_noaudio=video.killaudio()
    a=video_noaudio.Trim(0, n1-1)
    b=video_noaudio.Trim(n1, n2) # to remove
    c=video_noaudio.Trim(n2+1, 0)
    d=ffvideosource("C:\Users\davex\Desktop\test_trim. mp4", track=-1, seekmode=0) # to insert
    d=d.converttoyv12()
    video2=a+d+c
    # convert color space to YUY2
    video2_yuy2=video2.ConvertToYv12()

    audiodub(video2, audio)


    My version of ffms2.dll is 2.27.0.0 1/8/2018
    Quote Quote  
  7. Member
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    Thanks davex for your code.

    I still have the same problem: the file elaborated with the script has a different frame number than the original!

    What I do, following your example:

    Code:
    loadPlugin("... ffms2-2.23.1-msvc\x86\ffms2.dll")
    Import("... ffms2-2.23.1-msvc\FFMS2.avsi")
    
    n1=27
    n2=1134
    
    video=FFVideoSource("... original.avi", track=-1, seekmode=0)
    
    a=video.Trim(0, n1-1)
    b=video.Trim(n1, n2)
    c=video.Trim(n2+1, 0)
    d=FFVideoSource("... original.avi", track=-1, seekmode=0).Trim(n1, n2)
    a+d+c
    Frame number of original.avi opened in VD is 0:1365; frame number of script.avs opened in VD is 1353!

    How is it possible? I remove and add the same sequence! The same does not happen with AviSource().
    I will try to use same ffms2 version as yours...
    Last edited by lollo; 4th Jul 2018 at 16:10.
    Quote Quote  
  8. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Originally Posted by lollo View Post
    Thanks davex for your code.

    I still have the same problem: the file elaborated with the script has a different frame number than the original!

    What I do, following your example:

    Code:
    loadPlugin("... ffms2-2.23.1-msvc\x86\ffms2.dll")
    Import("... ffms2-2.23.1-msvc\FFMS2.avsi")
    
    n1=27
    n2=1134
    
    video=FFVideoSource("... original.avi", track=-1, seekmode=0)
    
    a=video.Trim(0, n1-1)
    b=video.Trim(n1, n2)
    c=video.Trim(n2+1, 0)
    d=FFVideoSource("... original.avi", track=-1, seekmode=0).Trim(n1, n2)
    a+d+c
    Frame number of original.avi opened in VD is 0:1365; frame number of script.avs opened in VD is 1353!

    How is it possible? I remove and add the same sequence! The same does not happen with AviSource().
    I will try to use same ffms2 version as yours...
    Post the mediainfo report (text view) of your source
    Quote Quote  
  9. Member
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    Report attached; please also consider that the acquired tape was damaged: maybe there are missing frames in the file causing ffms2 (but not avisource) to fail...

    General
    Complete name : C:\Users\giuse\Videos\Acquisizioni\ufo_sII1a_gsn_r e_acquired_3_cut.avi
    Format : AVI
    Format/Info : Audio Video Interleave
    File size : 359 MiB
    Duration : 54 s 600 ms
    Overall bit rate : 55.2 Mb/s
    Writing library : VirtualDub build 35491/release

    Video
    ID : 0
    Format : HuffYUV
    Format version : Version 2
    Codec ID : HFYU
    Duration : 54 s 600 ms
    Bit rate : 53.7 Mb/s
    Width : 720 pixels
    Height : 576 pixels
    Display aspect ratio : 5:4
    Frame rate : 25.000 FPS
    Standard : PAL
    Color space : YUV
    Chroma subsampling : 4:2:2
    Bit depth : 8 bits
    Scan type : Interlaced
    Bits/(Pixel*Frame) : 5.175
    Stream size : 349 MiB (97%)

    Audio
    ID : 1
    Format : PCM
    Format settings : Little / Signed
    Codec ID : 1
    Duration : 54 s 600 ms
    Bit rate mode : Constant
    Bit rate : 1 536 kb/s
    Channel(s) : 2 channels
    Sampling rate : 48.0 kHz
    Bit depth : 16 bits
    Stream size : 10.00 MiB (3%)
    Alignment : Aligned on interleaves
    Interleave, duration : 40 ms (1.01 video frame)
    Interleave, preload duration : 500 ms
    Quote Quote  
  10. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Perhaps ffmpegsource has an issue with huffy, I don't have a test video on hand to look at it.
    It works for most things quite well. Perhaps you should switch back to Avisource
    and test the individual segment lengths as was suggested earlier

    I ran the above script on an xvid avi and it worked OK, the resulting file had the same amount of frames
    as the original and the joined locations were smooth (no unnatural movement to indicate missing or added frame)
    Quote Quote  
  11. Member
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    Yes, I came to the same conclusion: ffms2 does not like huffyuv; strange because the video is compressed but in an (easy to "decode") lossless way.

    it was worth to try anyhow. I will keep avisource() for reading the file, and use only avisynth for the cut/trim/insert. (suggestion from manono, it is working).

    Thanks a lot for your support!
    Quote Quote  



Similar Threads