VideoReader reads ".h264" video compression file with error "Caught unexpected exception of unknown type."

50 次查看(过去 30 天)
Initially when I tried to use the VideoReader function to read the ".h264" video compression format file I got the error "Unable to determine the codec required." Then I learned from the Internet that I needed to install the "Media Player Codec Pack" package to read it correctly, so I successfully installed the package from this link, and when I read it again using VideoReader, I got the following error: "Caught unexpected exception of unknown type."
videoPath = "myvideo.h264";
info = mmfileinfo(videoPath)
info =
struct with fields:
Filename: 'myvideo.h264'
Path: 'E:\workDir'
Duration: 0
Audio: [1×1 struct]
Video: [1×1 struct]
info.Video.Format
ans =
'MPEG2'
ENVIRONMENT: Matlab R2022b, windows 10
Note: Since I installed this package, I can play ".h264" files normally with the windows media player that comes with my windows system.
  2 个评论
Walter Roberson
Walter Roberson 2023-1-29
Use a tool such as VLC to determine which codec was used. The codec is a 4 character code (so it is not 'MPEG2' which is 5 characters)
cui,xingxing
cui,xingxing 2023-1-30
@Walter Roberson , I use potplayer to get codec infomation, screenshot is below.
[Filter Usage List]
(1) Built-in Raw Video Source
(2) Built-in Video Codec/Transform
(3) Enhanced Video Renderer(Custom Present)
[Video Information]
Video Encoding: H264 - Built-in FFmpeg decoder (h264, Thread Frame)
Input format: H264 (24 bits)
Input size: 1280 × 960 (1.33:1)
Output format: YV12 (12 bits)
Output size: 1280 × 960 (1.33:1)
Frame rate: 15
BitRate: Unknown
so the codec is 'H264',and then?

请先登录,再进行评论。

采纳的回答

cui,xingxing
cui,xingxing 2023-1-30
编辑:cui,xingxing 2024-4-27
After much trial and error, I was lucky enough to find a solution that worked for me, and I am sharing it with you so that I can help others.
The prerequisite is to download the ffmpeg audio/video open source tool, download the binary executable for your platform here. I then converted the original video to avi format in the terminal by using the following command, which was subsequently read by matlab properly.
ffmpeg -i myvideo.h264 -vcodec copy test.avi
note: out put video 'test.avi' is same codec as original 'myvideo.h264'
Reference:
-------------------------Off-topic interlude, 2024-------------------------------
I am currently looking for a job in the field of CV algorithm development, based in Shenzhen, Guangdong, China,or a remote support position. I would be very grateful if anyone is willing to offer me a job or make a recommendation. My preliminary resume can be found at: https://cuixing158.github.io/about/ . Thank you!
Email: cuixingxing150@gmail.com

更多回答(0 个)

标签

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by