损坏的 MP4 视频文件修复

上直播课使用 OBS 对屏幕进行录制,在录制过程中难免会发生许多小意外,例如突然停电(草,一天停 4 次电),或者不小心按到关机键(草,已废掉关机键)由于录制没有执行保存操作(丢 header?),视频文件损坏…… 所以怎么修复呢?

网上冲浪后找到了一个可以用的程序,可以帮助你修复损坏视频

有 dalao 制作出了 GUI 版本,可以直接下载使用,方便简单~

https://github.com/Tornadocraver/GoPro-Video-Recovery/releases

据说大疆无人机录制的视频 h264 h265 都能修复

当然你也可以命令行手动操作 ↓↓↓

recover_mp4.exe 手动操作

你需要依次下载:

说明:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
recover_mp4 v1.92 (C) 2011-2017 Dmitry Vasilyev <slydiman@mail.ru>
http://slydiman.me

This utility can recover video and audio streams from unfinalized MP4/MOV/3GP files without (or empty) header.
You may got the unfinalized file in case of damaging camcorder during recording or such.

Supported video formats: AVC/H.264, HEVC/H.265

Supported audio formats: AAC, ADPCM (Intel), MP3, PCM (LE, BE, float), RAW

Usage:
recover_mp4 in_good_similar.mp4 --analyze
recover_mp4 in_corrupted.mp4 {out_video.h264 | out_video.hevc | --novideo}
{out_audio.aac | out_audio.wav | out_audio.mp3 | out_audio.raw | --noaudio} [options]

Options:
--start <hex> read from position (ignore mdat atom)
--end <hex> end position (ignore mdat atom). Specify 0 for EOF
--avcidrmax <hex> ignore AVC NAL units (IDR) with the size above than <hex> bytes
--avcxmax <hex> ignore AVC NAL units (non IDR) with the size above than <hex> bytes
--aaclong
--aacmin <hex>
--pcmmin <hex>
--pcmfix <hex>
--verbose

--gopro4 use Ambarella templates and detect GoPro4 specific data (default for MP4 files)
--ambarella use Ambarella templates (ignore GoPro4 specific data)
--lav use Lav/ffmpeg templates
--mainconcept use Mainconcept templates
--novatek use car DVR templates based on Novatek (DV turnkey, Street Guardian, etc.)
--qt use QuickTime templates (default for MOV files)
--iphone4 use iPhone4 templates
--eos use Canon EOS 5D Mark II, 7D, 550D templates
--eos3 use Canon EOS 5D Mark III, 7D Mark II, 100D templates
--eos4 use Canon EOS 5D Mark IV templates
--canon use Canon SX, EOS 80D templates
--vmix use vMix templates
--wowza use Wowza templates
--blackmagic use BlackMagic templates
--avermedia use AVerMedia Live Gamer Portable C875 templates
--lumia use Lumia templates
--panasonic use Panasonic DMC-G7, DMC-GX80, DMC-G85, DMC-GH4, DC-GH5, HC-X1000 templates
--sony use SONY A7S [Mark II], AX1E, NX5R, A6000, HDR-CX405, HDR-CX625 templates
--drim use DRIMeIII templates (Samsung NX1000 camcorder)
--drim5 use DRIMeV HEVC/H.265 templates (Samsung NX1/NX500 camcorder)
--tomtom use TomTom Bandit Action Camera templates
--icat use iCatch templates
--cgo3 use cgo3 templates
--dji.avc use DJI.AVC Phantom (H.264) templates
--dji.hvc use DJI.HVC Phantom (H.265) templates
--hevc use generic HEVC/H.265 templates
--ext use generic templates for any other camcorder or smartphone, Open Broadcaster Software, etc.

Step 1: Use any good previous file with the same resolution and bitrate to generate the header files, for example

>recover_mp4.exe good.mp4 --analyze

It will create files 'video.hdr' and 'audio.hdr' in the current directory and print instructions (ffmpeg options, etc.).

Step 2: Recover streams from the corrupted file, for example

>recover_mp4.exe bad.mp4 recovered.h264 recovered.aac

Note: Files 'video.hdr' and 'audio.hdr' must be exist.
Probably you need to add a specific option (look at instructions from step 1).

Step 3: Use any other utility (Yamb or ffmpeg for example)
to recreate the MP4/MOV file from the streams (recovered.h264 and recovered.aac).

>ffmpeg.exe -r 30 -i recovered.h264 -i recovered.aac -bsf:a aac_adtstoasc -c:v copy -c:a copy recovered.mp4

Note MP4 does not support PCM sound, you must create MOV in this case:

>ffmpeg.exe -r 30 -i recovered.h264 -i recovered.wav -c:v copy -c:a copy recovered.mov

In case of ADPCM audio:

>ffmpeg -r 30 -i recovered.h264 -i recovered.wav -c:v copy -c:a adpcm_ima_wav recovered.mov

Note: 30 is FPS in these examples. Specify your correct value.
In case of 29.97 I suggest to specify 30000/1001 instead.
本站文章除注明外均采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议进行许可 ヾ(゚ー゚ヾ)
分享到