有什么办法可以修复这个在录制过程中被截断的 mp4

有什么办法可以修复这个在录制过程中被截断的 mp4

我用安卓手机拍了一段视频,但没能正确按下“停止”按钮。因此我的手机磁盘内存不足,视频应用程序可能只是截断了该文件。

将文件(大小为 2.1 GB)复制到我的 ubuntu 桌面后,我尝试使用 运行它mplayer。输出为:

MPlayer 1.2.1 (Debian), built with gcc-5.4.0 (C) 2000-2016 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing 20190215_141432.mp4.
libavformat version 56.40.101 (external)
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f0685aced80]Protocol name not provided, cannot determine if input is local or a network protocol, buffers and access patterns cannot be configured optimally without knowing the protocol
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f0685aced80]Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(tv, bt709), 1920x1080): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
LAVF_header: av_find_stream_info() failed
[lavf] stream 0: video (h264), -vid 0
VIDEO:  [H264]  1920x1080  24bpp  90000.000 fps    0.0 kbps ( 0.0 kbyte/s)
Clip info:
 major_brand: mp42
 minor_version: 0
 compatible_brands: isommp42
 creation_time: 2019-02-15 14:06:39
Load subtitles in ./
Failed to open VDPAU backend libvdpau_va_gl.so: cannot open shared object file: No such file or directory
[vdpau] Error when calling vdp_device_create_x11: 1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 56.60.100 (external)
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Audio: no sound
Starting playback...
V:   0.0   0/  0 ??% ??% ??,?% 0 0 


Exiting... (End of file)

有什么办法可以解决这个问题吗?也许只是一些元数据需要更正。

我也尝试过这个但输出是一样的:

mplayer -lavfdopts analyzeduration=120 20190215_141432.mp4

然后我尝试剪辑视频

ffmpeg -probesize 1000M -analyzeduration 1000M 
    -i 20190215_141432.mp4 -pix_fmt yuvj420p 
    -ss 00:00:00 -c copy -t 00:05:30 new.mp4 

但输出大致相同:

ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
[...]
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x182d380] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(tv, bt709), 1920x1080): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
20190215_141432.mp4: could not find codec parameters
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20190215_141432.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2019-02-15 12:06:39
  Duration: 00:19:49.40, bitrate: 10308 kb/s
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), none(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 10.94 fps, 90k tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 180
      creation_time   : 2019-02-15 12:06:39
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -180.00 degrees
[...]
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)

请注意,我指定了pix_fmt, probesizeanalyzeduration但收到了回复

未指定像素格式。考虑增加“analyzeduration”和“probesize”选项的值

顺便说一句:我pixel_format也尝试过。

到目前为止,我最后一次尝试是使用 untrunc。输出为:

Repair: 20190215_141432.mp4
Failed to parse atoms in truncated file

更新(编辑过的)答案(由 Fabby 编辑):

我试过这个

ffmpeg  -i 20190215_141432.mp4 -probesize 100M -analyzeduration 100M -map_metadata -1 -c:v libx264 -strict -2 -c:a libmp3lame -b:a 512K new.mkv

(并使用诸如1024M2G之类的值4G以及放置参数(如在这里建议),但输出基本上是:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0xc0c4a0] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(tv, bt709), 1920x1080): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
20190215_141432.mp4: could not find codec parameters
[...]
Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (new.mkv) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
[...]
[buffer @ 0xc137e0] Unable to parse option value "-1" as pixel format
    Last message repeated 1 times
[buffer @ 0xc137e0] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0xc133e0] Error applying options to the filter.
Error opening filters!

现在我要解决这个问题。

原因:使用 或其他工具剪切、合并视频甚至旋转视频都非常简单ffmpeg/mencoder。剪切、合并、旋转操作(根据我的理解)首先应该重新排列元数据。

在这种情况下,元数据是存在的并且有效的(例如持续时间、格式、创建时间……)。那么,为什么在这种情况下修复元数据如此困难?非常烦人的是命令输出,声称没有指定像素格式等等……

毕竟。我以为修复这个视频只需要一个有价值的提示或一些神奇的规范工具,但毕竟我的生活并不依赖于此。

答案1

很抱歉,但对于 .MP4 文件,您需要文件的页眉和页脚才能播放,因此需要完全转码(而不仅仅是复制)可能使其可读:

ffmpeg -i 20190215_141432.mp4 -probesize 100M -analyzeduration 100M -map_metadata -1 -c:v libx264 -strict -2 -c:a libmp3lame -b:a 512K 20190215_141432.mkv

如果这没有帮助,则内容确实丢失了,因为无法从您获得的数据中重建页脚。

相关内容