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

50 Ansichten (letzte 30 Tage)
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 Kommentare
Walter Roberson
Walter Roberson am 29 Jan. 2023
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 am 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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

cui,xingxing
cui,xingxing am 30 Jan. 2023
Bearbeitet: cui,xingxing am 27 Apr. 2024
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

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by