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

38 views (last 30 days)
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 Comments
cui
cui on 30 Jan 2023
@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?

Sign in to comment.

Accepted Answer

cui
cui on 30 Jan 2023
Edited: cui on 30 Jan 2023
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'

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!