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:
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.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)
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)
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 11 of 11
Thread
-
-
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?
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. -
First of all, many thanks to all of you for your help on this topic.
@ davexnet
try ffvidesource and ffaudiosource (ffms2.dll)
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 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?
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
Yes, don't use Full Processing Mode
editor working in HuffYUV
It'll tell you the colorspace
@jagabo
Check the lengths of b and d.
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! -
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 -
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
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.
-
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 -
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) -
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!
Similar Threads
-
Trim problem with AVISynth
By smike in forum EditingReplies: 5Last Post: 9th Aug 2016, 09:20 -
AviSynth Audio Trim Question
By Akai-Shuichi in forum RestorationReplies: 2Last Post: 31st Mar 2016, 18:27 -
avisynth: how trim using for example 0:00:31.040000 ?
By marcorocchini in forum Newbie / General discussionsReplies: 9Last Post: 31st Oct 2014, 15:07 -
AVISynth TRIM results in wrong frame number in VirtualDub
By Budman1 in forum Video ConversionReplies: 33Last Post: 15th Jun 2014, 15:24 -
Cut/Trim the first few second of MKV File
By jslegers73 in forum EditingReplies: 16Last Post: 24th May 2014, 22:51