0

我已经能够毫无问题地记录 .h264 文件,无论是使用 raspivid 还是通过 Python,但无论我尝试什么,我都无法将它们转换为 .mp4、.mkv 或 .avi 文件。

我尝试使用 MP4box(在多个地方建议)和 mkvmerge 进行转换,但无济于事。

当我使用 MP4box(MP4box -add <source.h264> <dest.mp4>)时,我得到:

AVC-H264 import - frame size 1920 x 1080 at 25.000 FPS
WARNING: NAL Unit type 0 not handled - adding5/100)
AVC Import results: 44 samples - Slices: 3 I 41 P 0 B - 0 SEI - 3 IDR
Saving video.mp4: 0.500 secs Interleaving

然后我尝试使用 VLC 播放这个文件,它没有报错,但显示乱码数据。

需要明确的是,相机工作正常(使用 Python 代码显示完美的视频,并且 raspistill 输出完美的 jpg 文件)。我也尝试了不同的相机。

尝试使用 mkvmerge :

pi@raspberrypi:~/cam $ raspivid -o test.h264 -fps 30 -t 15000 -w 1920 -h 1080
pi@raspberrypi:~/cam $ mkvmerge --default-duration 0:30p -o video.mkv test.h264
mkvmerge v31.0.0 ('Dolores In A Shoestand') 32-bit
'test.h264': Using the demultiplexer for the format 'AVC/h.264'.
'test.h264' track 0: Using the output module for the format 'AVC/h.264 (unframed)'.
The file 'video.mkv' has been opened for writing.
Error: 'test.h264' track 0: mkvmerge encountered broken or unparsable data in this AVC/h.264 video track. Either your file is damaged (which mkvmerge cannot cope with yet) or this is a bug in mkvmerge itself. The error message was:
Success
pi@raspberrypi:~/cam $

这是在树莓派 4 上。

可以在此处找到示例文件:https ://filebin.net/c40usz0crhgggadf 创建于:raspivid -t 30000 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 -o pivideo.h264

4

1 回答 1

0

我将自己对此作出回应。进行“apt-get upgrade”后,问题就消失了。

如果有人想找出根本原因,这就是 apt-get 所做的:

The following packages will be upgraded:
  bind9-host bluez-firmware firmware-atheros firmware-brcm80211 firmware-libertas firmware-misc-nonfree firmware-realtek libbind9-161 libdns-export1104 libdns1104 libgs9 libgs9-common libisc-export1100 libisc1100 libisccc161
  libisccfg163 liblwres161 libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel raspberrypi-kernel-headers raspi-config rpd-plym-splash
The following packages will be DOWNGRADED:
  python3-pgzero
27 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
于 2020-08-29T16:52:25.667 回答