|
|
| robinhutter |
Posted: Jul 26 2014, 10:01 AM |
 |
|
Newbie

Group: Members
Posts: 7
Member No.: 26003
Joined: 13-August 09

|
Hi folks,
I have been using VirtualDub to cut videos for some years now. I used to process MPG/AVI DivX videos (OnlineTvRecorder). The MO to remove the commercials was simple: Mark the first frame Start. Use Shift-Right to move to the next keyframe until the first keyframe of the movie appears after the commercial. Usually I go too far, so back using Shift-Left and maybe forward again using Shift-Right until I am at the correct keyframe. Mark End. Cut. Done. Now I have begun to process HQ videos which use H.264. Now I fast-forward to the movie after the commercial. I "rewind", move forward until I see the first keyframe of the movie on the screen. I mark End, cut and ... after replaying the cut video I find that VD cuts at a totally different frame. I.e. the frame that VD uses for cutting and the frame that I see on screen is not the same! I have tested it over and over again. It only gives me problems when I use backwards motion. If I just move from left to right everything seems to be OK, but if I move back, trouble starts. Can someone explain what is happening - and more important: How can I avoid this???
The file specs are: 720x576, 25 fps, Decompressor: x264fvw - H.264/MPEG-4 AVC codec, audio: 48 kHz MP3 (Fraunhofer) I am using VD 1.10.4 (Build 35491)
Tia for any help Robin <>< |
 |
| dloneranger |
| Posted: Jul 26 2014, 10:54 AM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
That's because video has gotten more complicated over the years
Short version You can only start a cut on a 'key frame' Shown as [K] in the status bar You can jump to the next/previous one with the two buttons that have a door key symbol on them There can be a delay in the frame shown compared to the frame you want and you seem to get sudden 'jumps' in the sequence
---------------
Very long version
Video used to be one complete picture after another Editing was easy but files were big. Very, very big
Then it changed (to improve compression) to one complete picture (a key frame) followed by lots of pictures of 'only what had changed since the previous picture' until the compressor decides to start again with another key frame (usually about 300 frames or a scene change) (p_frames) This is just like film cel-animation done with clear sheets over the background (https://www.youtube.com/watch?v=oktGlZQgYWs) eg http://nickyguides.digital-digest.com/keyframes.htm Now you could only start a cut on the 'key frame' as anywhere else didn't have a complete picture
Then to improve compression again they started to use bits of pictures that are in the future as well (b-frames) This added another complication, to get a full picture you need all the previous frames and ones that you haven't even read off the disk yet eg http://upload.wikimedia.org/wikipedia/comm..._frames.svg.png So to do that, you need to delay the video at the beginning until you have enough frames to show a complete picture That works fine for playing back, but means you get a delay effect when editing equal to however many it needed to buffer to begin with Now you could only start a cut on the 'key frame', with the added complication of only being able to end a cut an the same way
....sigh, editing just got hard.....
The other way of doing it is for an input plugin like ffmpeg plugin to do all the reading of the file Then the plugin does all the shuffling around in the file and goes taaa daaa, here's the real frame 10 etc Sounds good, but there's a slight catch explained below
Both ways work and each have pro's and con's
Method 1 -> Virtualdub doing it all Lets you do fast editing like just cutting bits out and saving in 'direct stream copy mode' pro-> very fast saving in direct stream copy mode con 1-> a pain to get the correct frame con 2-> modern video also has each frame timestamped, cutting a bit out of the middle of the video screws up the timestamps and some video players can pause or get stuck at the cut
Method 2 -> using a plugin like ffmpeg plugin or directshow plugin Shows you the correct frame pro-> easy editing as you see the correct frame con 1-> you can't do direct stream copying, as the plugin gives back the complete picture, not all the 'pieces' that a direct copy needs con 2-> that means you have to recompress the video, and all the learning etc involved with that
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |
| robinhutter |
| Posted: Jul 26 2014, 03:52 PM |
 |
|
Newbie

Group: Members
Posts: 7
Member No.: 26003
Joined: 13-August 09

|
Thanks, dloneranger for your reply. I know the concept of keyframes. And I know that I can end sequences where I want, but have to start with keyframes. But this is no difference between DivX and H.263 movies. BUT, my problem is totally different.
Example (picked at random). In my version of "Harry and Sally" frame 6975 shows Harry and Sally in the car talking. (https://dl.dropboxusercontent.com/u/36541389/HaS1.jpg)
I move ahead 5 keyframes taking me to frame 7804. Then back 5 keyframes. The status line in VirtualDub shows the same frame as before: 6975 and it is a keyframe [K]. BUT the frame displayed is the car driving down the road, i.e. not the frame that had been displayed as frame 6975 seconds before. (https://dl.dropboxusercontent.com/u/36541389/HaS2.jpg).
In fact it is frame 7613 - 4 keyframes further. If I move ahead 10 keyframes and back 10 keyframes the result is the same. Status: 6975, but displayed: 7613. And it is not a matter of speed. I can wait for minutes, hours or days. The frame displayed does not change! I have to be extremely careful that the frame displayed is really the frame where VD makes the cut... This makes editing a PITA! |
 |
| dloneranger |
| Posted: Jul 26 2014, 04:04 PM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
It's not a delay as in 'plz wait im busy' But a buffer delay due to the number of bframes between moving and getting an output
Easiest way of seeing it is to move 1 frame forward a few times, then jump to the next keyframe and then carry on moving forwards frame by frame You'll see the video display the actual jump a few frames later than pressing the button
Here's the kind of thing that's happening - for example with just a 2 frame delay
Displayed frame # in virtualdub Real frame being shown 100 101 102 103 104 105 106 107 108 109 110 * 109 108 107 106 105 098 099 100 101 102 103 104 105 106 107 108 * 109 110 109 108 107
The * is where you start going backwards So at the frame you see shown as 105 you're being shown frame 103, go right 5 frames and left 5 frames, and you're seeing frame 107
There's a test clip you can play with - a sequence of numbers that increments 1 per frame https://dl.dropboxusercontent.com/u/1702491...umbers%20B8.avi
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |
| robinhutter |
| Posted: Jul 26 2014, 10:13 PM |
 |
|
Newbie

Group: Members
Posts: 7
Member No.: 26003
Joined: 13-August 09

|
OK very insightful demo. Now I see what is happening. But what can I do to cut at the exact frame I want? I mean, you wrote some hints in your first reply, but I'm not quite sure I get what I need to do... Can I use VirtualDub with ffmpeg or directshow? Recompressing would take much longer, but given the time I need to find the correct frames... And btw, I guess there is no way to determine the buffer delay? |
 |
| dloneranger |
| Posted: Jul 26 2014, 10:29 PM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
Finding the delay is trial and error, step some frames forwards, then to the next key frame and move forwards until it shows the change? Not sure if that would actually work though...... you'd have to try (that test clip could be useful for verification here)
For direct stream copy you're fairly stuffed, as you can only start on a key frame anyway Unless you use 'smart rendering' and can match the codecs settings properly and this can be tricky (smart rendering recompresses the video until it gets to a key frame and then just copies the rest)
If you choose to recompress the video, then you can use an input plugin like FFMpeg plugin (in my sig) to load the video
If you've never used a plugin to load a video here's a quick howto quoted from Abrazo (if you use 64bit virtualdub then use plugins64 and the 64bit plugin) Or you can use the installer instead of the .zip on the sourceforge page
| QUOTE | Installation goes by unzipping the 32-bit branch of files to your VirtualDub 32-bit installation. So you should get a similar situation as the one below, when looking in Windows Explorer: C:\Program Files\VirtualDub 1.10.5\plugins32\FFInputDriver.vdplugin C:\Program Files\VirtualDub 1.10.5\plugins32\ffdlls\avcodec-55.dll C:\Program Files\VirtualDub 1.10.5\plugins32\ffdlls\avformat-55.dll C:\Program Files\VirtualDub 1.10.5\plugins32\ffdlls\avutil-52.dll C:\Program Files\VirtualDub 1.10.5\plugins32\ffdlls\swscale-2.dll When opening the file via the Open video file... dialogbox (in VirtualDub 1.10.5.xx) you should do one single click on the file, and then at "Files of type:" select "FFMpeg supported files". Then click the Open-button. |
If direct stream copy is what you need, and you can set the codec to match for smart rendering then you could always cut a bit more than you need and do a fade-in to hide the beginning bit you don't want Here's a demo I did of using the curve editor to fade effect in/out https://www.youtube.com/watch?v=hVLsDW5nQso You could use the fill filter set to black instead of the demo'd filter
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |