How can I read Intra coded frames from a video?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
zealous
el 23 de Jul. de 2015
Comentada: Walter Roberson
el 25 de Ag. de 2015
I am in need of reading the intra frames of a video to check whether it is edited or not. I could do it with single JPEG images as it can be read using jpeg_read. Read that videos vith MPEG codec is formed out of Intra, Predictive and Bidirectionally predictive frames. Is there any way in MATLAB to extract these frames from a video instead of simple RGB frames?
0 comentarios
Respuesta aceptada
Dinesh Iyer
el 23 de Jul. de 2015
Editada: Dinesh Iyer
el 23 de Jul. de 2015
Zealous,
The notion I, P and B frames only applies to an encoded stream. It determines how the frames must be decoded and the level of compression of each frame. Once you decode the video, each of these frames are converted into either RGB or YUV colorspace. VideoReader currently supports only RGB frames.
If you are asking whether you can read the encoded frames as they are present in the video stream using MATLAB functions such as VideoReader, the answer is no. You can always use low-level file I/O such as fopen, fread and directly parse the bit-stream but that requires knowledge of the file format.
If you are asking whether it is possible to do an operation such as "read me all the P-frames in the video stream", the answer again is not directly. You can do this indirectly using tools such as ffmpeg and MATLAB. I can outline the steps but have no code to offer:
1. Download ffmpeg tools. it has a utility called ffprobe which dumps out info about the file.
2. Using the MATLAB's system command, execute:
ffprobe -show_frames -select_streams v:0 myfile.mpg > C:\Temp\myfileinfo.txt
This will generate a text file with information about each frame. You can do some clever text processing on this file using TEXTSCAN and look for PICT_TYPE=P and identify which frames are P-frames.
3. The number of occurrences of the string "PICT_TYPE=" indicates number of frames.
4. Use these indices to read frames using VIDEOREADER. This will decode the P-frames and return RGB data.
Hope this helps.
Dinesh
8 comentarios
Walter Roberson
el 25 de Ag. de 2015
jpg file format is in part governed by http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=54989, the JPEG File Interchange Format (JFIF) and that data tends to get wrapped by the standard about "Registration of JPEG profiles, SPIFF profiles, SPIFF tags, SPIFF colour spaces, APPn markers, SPIFF compression types and Registration Authorities (REGAUT)"
For example, how to include an EXIF header is part the formal structure of jpg files, but is not part of the section of the standard about DCT and so on. MPEG can incorporate the relatively low level JFIF without having to support jpg files.
Más respuestas (0)
Ver también
Categorías
Más información sobre Denoising and Compression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!