How can I validate a video file from a script?

后端 未结 5 1251
一个人的身影
一个人的身影 2021-02-09 03:17

I have a server with lots of video files. After a restore, I noticed that the checksum of a couple of files changed. Since I don\'t have checksums for all files, I wanted write

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-09 04:01

    Short of watching all the videos, there's no "perfect" way to do this.

    Video files are quite robust - as an experiment I took a random MPEG-4 video file, opened it in a hex-editor and started changing bytes.. mplayer and Quicktime still played it back without errors.

    I had to delete thousands of bytes before getting any error from mplayer:

    ...
    [mpeg4 @ 0x6762b0]marker does not match f_code
    [mpeg4 @ 0x6762b0]marker does not match f_code
    [mpeg4 @ 0x6762b0]concealing 852 DC, 852 AC, 852 MV errors
    [mpeg4 @ 0x6762b0]header damaged:  0.055  16/ 16 15%  1%  3.5% 0 0 
    Error while decoding frame!
    

    It wouldn't be difficult to write a script that runs mplayer on each video, and checks the output for error messages/warnings, but unless the changed bytes are in the file header, or a lot of data was changed, you'll never find them all

提交回复
热议问题