[ How To ] Come recuperare un video Mp4 danneggiato.

Creato il 03 gennaio 2013 da Contazrazor

Come per tutte le guide presenti sul blog, anche oggi ci arriva una richiesta particolare che ci spinge a scriverne una: Un Video MP4 danneggiato, come recuperarlo? ecco due modi per riavere i nostri file.

File corrotti, si sente parlare sempre di queste sfortune, corrotti per un trasferimento fallito o danneggiati a causa di un’interruzione imprevista nella loro creazione; Oggi ci concentreremo sui file MP4 e avi su due principali modalità per recuperarli, la prima nel caso non fossero particolarmente danneggiati, la seconda nel caso in cui nemmeno VLC ci possa dare risposta.

Proprio per la precedente considerazione, prima di procedere, consigliamo di provare ad avviare il video, Mp4 o avi che sia, con VLC o con KANTARIS Media Player, questi infatti, possedendo un loro tool in grado di riparare i file corrotti che possono riprodurre, potrebbero risolvere il problema, se cosi non fosse ecco come agire.

1° Metodo

  1. Per il primo metodo, in grado di recuperare la maggior parte dei file video, ci affideremo d un programma chiamato DivFix++, quale potrete scaricare cliccando il link a seguito:
  2. Dopo aver scaricato il programma, estraiamolo con un programma a nostro piacere, in tutto il suo contenuto ed avviamo l’applicativo. Dovremmo trovarci di fronte ad un’interfaccia simile a quella seguente.
  3. Selezioniamo ora, cliccando in basso a sinistra su “Add Files” il file video da riparare, il quale comparirà nela schermata di sinistra.
  4. Deselezioniamo le caselle in basso a sinistra, Ovvero “Cut Out Bad Parts” e “keep Original File” e premiamo su ” Strip Indext” a sinistra, per pulire l’indice corrotto del file.
  5. Finalmente premiamo su “ Fix” e aspettiamo che il file venga riparato, altrimenti possiamo, prima di premerlo, ri-selezionare le caselle precedenti, prendendo i dovuti accorgimenti.
  6. Segnaliamo anche che per un uso futuro, si potrà, attraverso le preferenze del programma, cambiare la lingua ed impostare la cartella predefinita del lettore multimediale in nostro possesso. 

2° Metodo

Hex Editing

L’Hex Editing è quel processo, secondo il quale, potremo andare a modificare direttamente il programma o file in nostro possesso, ad un livello di programmazzione basso, ancor più dell’assembly ( consultare wikypedia per approfondire) , esadecimale appunto, ( Per livelli di programmazioni alti si intendono i linguaggi di programmazione C, C++, Visual Basic etc..).

Il Metodo che state per vedere, a titolo informativo, è lo stesso che può essere utilizzato, come molti avranno intuito, per modificare degli applicativi a pagamento per renderli gratuiti, oppure per le crack  a giochi che ne permettono l’avvio senza CD / DVD, su richiesta potremmo parlare anche di questo argomento. Senza digredire ancor più, torniamo a noi ed al nostro video ancora corrotto ( MP4 questa  volta).

Iniziamo introducendo la costruzione interna di un file MP4, e per far questo citiamo una spiegazione ben completa ed illustrata ( in inglese), necessaria a capire come faremo a riparare il nostro file:

Atoms, Boxes, Parents, Children & hex (oh my)

An MPEG-4 file is made of a number of discrete units called atoms (well, they were called atoms in the first version of the specification, now they are prosaically called ‘boxes’). An atom has a format:

Anything beyond that basic 8 bytes is either optional & defined by the hierarchy it is found in (moov.udta.meta.XXXX atoms have a format defined by Quicktime), or defined by the atom itself. The ftyp atom is ALWAYS first, and has a certain type of format – it tells what type of file it is & the basic versioning of the atom structures.

In the above example the moov atom has a length of 0x00001D38 or 7480 bytes. Immediately following the moov name however is a new atom. This is the mvhd atom, and its length is 0x0000006C or 108 bytes. Because 108 bytes is less than 7480 bytes, the mvhd atom is a child atom of the moov atom. The MPEG-4 specification says that either an atom can be a parent atom (as moov is a parent to mvhd) or it can carry some sort of information on it (as ftyp & mvhd show above), but not both.

The length of the atom is determined by the length of itself PLUS any and all atoms in the level immediately below it – not all the way down to the end of the hierarchy. For example, the moov atom sums the length of the mvhd atom and other atoms on the same level (not shown), but not children of mvhd – mvhd sums those lengths. The atoms in the level below sum the lengths in the atoms below them until you get to the end of a hierarchy. At that point the sum of that atom is:

4 bytes for the atom length
4 bytes for the atom name
??? bytes that are optional for any data it might hold

The minimum length of an atom then would be 8 bytes.

The ‘Atom Is A Parent Or Holds Data’ rule is made to be broken . Often the atom under moov.trak.mdia.minf.stbl.stsd is a parent and contains data. Apple’s drm implementation breaks this rule further. The other standard atom that breaks this rule is moov.udta.meta for historical reasons. Still, the MPEG-4 container is relatively easy to understand & highly flexible.

The most important part of an MPEG-4 file is the mdat atom – its where the actual raw information for the file is stored. This top level atom takes up the bulk of an MPEG-4 file. However, the moov atom comprises a number of different atoms and hierarchies, and provides for basic functionality – like specifying the dimensions of a video file, or the duration of a song.

uuid atoms are user-defined atoms, and are similar to normal atoms, but their name is 8 bytes (4 bytes holding uuid and the name of the uuid atom). Sony PSP mp4 files notably use uuid atoms. AtomicParsley supports setting & reading its own uuid atoms to carry supplemental metadata.

Avremo dunque compreso che un file MP4 è formato da tanti ” ATOM ” ed è proprio su questi che andremo a lavorare per rigenerare il nostro flusso video.

  1.  In Primis ci servirà un compilatore esadecimale, il quale potete scaricare direttamente dal link seguente, per maggior precisione si tratta di WinHEX
  2. per riparare il nostro video, andremo ad integrarvi un atom, non corrotto, e dunque andrà preso da un file, possibilmente della stessa provenienza. Per sicurezza facciamone una copia.
  3. Apriamo dunque il flusso video non corrotto con WinHex e, attraverso la funzione trova, o, a vostro divertimento, scrollando l’intero foglio Hex, andiamo a recuperare l’ATOM nominato esds.
  4. Cerchiamo dunque due parole da 4 byte:
    • mp4v : da questa parola di 4 byte ( 4 caratteri, ognuno formato da 8 bit ), inizia l’ATOM  esds
    • mdat : a quest’altra l’Atom Finisce.

    Dunque dovremo cercare queste due parole e selezionare una precisa porzione di testo, dovremo catturare con il puntatore a partire dai 4 byte precedenti alla scritta  esds , all’interno delle due parole precedenti, fino ai 4 byte precedenti la parola ” mdat”, esclusi apici naturalmente, ed esclusi questi 4 byte. Per maggior chiarezza consultare lo screenshot seguente.

  5. Copiato questo lembo di codice ed usciti dal file integro, rechiamoci a quello danneggiato ed incolliamo il codice prelevato tra l’atom ” ftyp “, e l’esds, all’inizio del file, anche in questo caso potete consultare la seguente screen
  6. Fatto ciò, salviamo il nostro video, non in formato Mp4 ma in formato    “  .mp4v  “
  7. Ora scarichiamo MP4Creator, programma che ci permetterà di riassemblare il flusso video, dal link seguente:
  8. Dezippiamo anche questo ed inseriamo l’eseguibile nella stessa directory ( cartella ) del video precedentemente salvato nel formato .mp4v ed avviamolo.
  9. Ora, dal pannello di controllo apertosi dinanzi a noi, digitiamo i seguenti comandi avendo l’accuratezza di sostituire ” nomevideodanneggiato ” con il nome reale e con stesso comportamenteo il rate.
  10. mp4creator --create=nomevideodanneggiato.mp4v --rate=30 --verbose video.mp4
  11. nel caso il rate fosse un problema, si può provare ad usare una modalità automatica, sostituendo il comando con :   –variable-frame-rate
  12. Arrivati alla fine, avremo il nostro video nominato ” video.mp4 ” rigenerato, per altre problematiche si potrà sfruttare senza problemi il programma audacity dal seguente link: http://audacity.sourceforge.net/

Nel caso di ulteriori problemi risolutivi o se siete soddisfatti, commentate pure a seguito.

Crediti:

Softpedia – Download & screenshots

Atomicparlsley – Costituzione MP4

x-wais – Download & info

sourceforge  – Download & info

Wirgilio-it – Screenshots & info

Contazrazor.


Potrebbero interessarti anche :

Possono interessarti anche questi articoli :