Crop .avi file
Afficher commentaires plus anciens
Hi,
I'm have a video .avi file that i want to crop for these dimensions: 767 410 166 165. This is the code I have now but I keep getting a error. I've learned that I can't do it with VideoReader or vision.VideoReader. Any suggestions are welcomed.
vid=VideoReader('bubbles.mov','Tag', 'My object');
vid_croppped=vid('767 410 166 165')
Réponses (1)
Image Analyst
le 8 Mai 2021
1 vote
See attached example and make the obvious simple modifications.
Write back if you can't figure it out.
12 commentaires
Katrina German
le 8 Mai 2021
Image Analyst
le 8 Mai 2021
It's not clear what you want to do. So you already "have the dimensions" to crop one video, and you cropped it. Then it sounds like you inserted that cropped video file into another one (because you said "inserted my video file"). OK, fine - you inserted a smaller frame onto a larger frame of another video. But it should not be blurry. It should be just a pixel for pixel replacement, so no blur unless it was blurred to start with.
Katrina German
le 8 Mai 2021
Image Analyst
le 8 Mai 2021
@Katrina German Again, it will not be blurry. If it is blurry, you're not looking at the inserted/cropped part of the video with the same size on the screen as your original video. Obviously if you make that part of the image 16 times as big, it will seem blurry because it has to interpolate the video to make it bigger. But if that's the case, then if you stretched the original video window to the same size as the video (so that the cropped/inserted video in the output video, and the same part of the scene in the input video were both the same size on the screen), then the original video would look blurry too. If you don't believe that, then attach your original video, the cropping coordinates, the output video onto which the cropped portion will be pasted, and your m-file for doing the copying and pasting and I'll take a look at it. If the videos are too big to attach, then use Google drive.
Katrina German
le 8 Mai 2021
Image Analyst
le 9 Mai 2021
OK. I don't see any question so I assume we're done now.
David Gill
le 21 Nov 2022
@Katrina German Hi, can you explain in more detail how your code above works please? I need to crop an AVI video as well. I dont know the exact dimensions, just that i want to remove the bottom 3 layers of pixels. Any help would be great, thanks.
Image Analyst
le 21 Nov 2022
@David Gill you can just use my attached demo but after the line
% Extract the frame from the movie structure.
thisInputFrame = read(inputVideoReaderObject, frame);
add this line to crop off the last 3 rows:
thisInputFrame = thisInputFrame(1:end-3, :, :);
David Gill
le 22 Nov 2022
Modifié(e) : David Gill
le 22 Nov 2022
Hi, thanks for the help. I proccessed it as you recommended but the output resolution is significantly lower. Any idea why? The input frames were 1044 rows by 1280 columns whereas the output is 261 rows by 320 columns, guessing this reduction in rows/columns has something to do with it?
additional info from command window:
General Properties:
Name: 'Newtrial 3_20220208.avi'
Path: 'C:\Users\davidgill\Desktop\WhiskerTracking [custom parameters]'
Duration: 250
CurrentTime: 0
NumFrames: 7500
Video Properties:
Width: 320
Height: 261
FrameRate: 30
BitsPerPixel: 24
VideoFormat: 'RGB24'
David Gill
le 22 Nov 2022
@Image Analyst update: I reduced the shrinkfactor to 1 and the resolution was drastically improved. Still not perfect though.
Image Analyst
le 22 Nov 2022
@David Gill you were supposed to modify the demo. You were supposed to realize that the resizing line in the demo is not what you want and to delete that line. If you do that there will be no change in resolution, only that the output video will be three lines shorter vertically.
David Gill
le 22 Nov 2022
Ah I see. thank you for clarifying.
Catégories
En savoir plus sur Video Formats and Interfaces dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!