How can I read Intra coded frames from a video?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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?
채택된 답변
Dinesh Iyer
2015년 7월 23일
편집: Dinesh Iyer
2015년 7월 23일
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
Thanks a lot. The reply is very helpful to understand the situation more clear. I think I can proceed with this method. But when I read the frame using video reader and save as JPEG, a decoding and a re-encoding takes place. Right? But I need the original encoded JPEG frame. Is there any way for that? Like, reading an image directly using jpeg_read() other than read using imread(), save as JPEG and then process.
Zealous,
When you read the frame you want, you do not have to save it as a JPEG. You can save it in an uncompressed format such as BMP or use a TIFF file.
Secondly, the nature of the compressed of the I-frames in the video file depend upon the codec used. The I-frames will not be JPEG encoded because each codec uses its own technique for intra-coding frames.
Dinesh
I am about to consider videos with MPEG codec only. They have JPEG encoded intra frames, as I understood. I am in need of the original compressed JPEG frames as it is embedded in the video.
MPEG-1 uses JPEG encoded intra frames; some of the later MPEG do not. http://www.eetimes.com/document.asp?doc_id=1275884
Note that JPEG encoded frame is not the same thing as jpg file format.
In any case, I am not aware of anyone having programmed MATLAB itself to do this. I have seen a number of students ask questions that imply that some professors believe that the code is available in MATLAB, but I did not find any implementations. It could be done; it is just tiresome to implement and likely to be error prone compared to calling upon an already-written and well-tested library.
It is not possible to get the original encoded frame using any of the video I/O functionality as the purpose of these is to decode the video and return decoded frames.
@walter Roberson "Note that JPEG encoded frame is not the same thing as jpg file format." How it differs? Atleast the key frames (I frames) has JPEG format, na?
@Walter Roberson @Dinesh Iyer Thanks for your helps. I have tried continueing with MPEG. But couldn't complete because I didn't get the originally encoded I frames. Hence chose some other algorithm.
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.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Video Formats and Interfaces에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
