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

52 ビュー (過去 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 2023 年 11 月 30 日
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:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by