Last modified by Jan Rhebergen on 2022/01/24 15:56

Hide last authors
Jan Rhebergen 1.1 1 Data wrangling is the process of cleaning and unifying messy and complex data sets for easy access and analysis. It can also mean fixing data that is somehow broken and unreadable.
2
3 == Reparing a ##mp4## video clip ==
4
5 An example could be repairing a video file that was closed improperly. The reason could be:
6
7 * a an empty cell-phone battery causing a crash of the camera app,
8 * a bad connection to an sdcard (i.e. physical contact issues),
9 * a media that is full or corrupted or,
10 * some other unspecified reasons.
11
12 Here we document a real example of an mp4 video clip which became corrupted due to the cellphone running out of power and the thus a premature end/crash of the android camera app.
13
14 In this case the error reported by VLC was:
15
16 (% class="box" %)
17 {{{(base) jan@beethoven:~/Desktop$ vlc 20211012_123750.mp4
18 VLC media player 3.0.11.1 Vetinari (revision 3.0.11.1-0-g52483f3ca2)
19 [00005587c32405b0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
20 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fca500ab3c0] moov atom not found
21 [00007fca18007de0] mp4 demux error: MP4 plugin discarded (no moov,foov,moof box)
22 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fca18c15400] moov atom not found
23 [00007fca18007de0] avformat demux error: Could not open /home/jan/Desktop/20211012_123750.mp4: Unknown error 1094995529
24 qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1590, resource id: 6299190, major code: 40 (TranslateCoords), minor code: 0
25 QObject::~QObject: Timers cannot be stopped from another thread
26 }}}
27
28 In this case the so called ##moov atom not found## message is an indication of an improperly closed video file. Problems like this are not unusual and mostly easy to fix. There are many online tools available most of which are not much more than wrappers around the famous ##ffmpeg## command line tool.
29
30 Sometimes a simple command like the one below can already be enough to fix the video clip. Sometimes it is a bit more involved. The easiest way to fix this is to download and compile from ##github## the ##untrunc## tool that uses avcodec libraries to effectively repair the ##mp4## video clip.
31
32 (% class="box" %)
33 {{{ffmpeg -i 20211012_123750.mp4 -c copy fixed_output.mp4
34 }}}
35
36 This did not work and produced an error message similar to the one mentioned above hence we proceed with the ##untrunc## tool as follows.
37
38 (% class="box" %)
39 {{{sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev
40 mkdir ~/source
41 cd ~/source
42 git clone https://github.com/anthwlock/untrunc.git
43 cd untrunc
44 make
45 ./untrunc ~/Desktop/good.mp4 ~/Desktop/20211012_123750.mp4
46 }}}
47
48 A sample file named #good.mp4## recorded on the same device is supplied to extract correct metadata from. This should produce a fixed version of the input file with the ##_fixed.mp4## suffix. All that remains now it to test it with the ##vlc## player.
49
50 (% class="box" %)
51 {{{(base) jan@beethoven:~/source/untrunc$ vlc ~/Desktop/20211012_123750.mp4_fixed.mp4
52 }}}