doc:appunti:linux:video:ffmpeg
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
doc:appunti:linux:video:ffmpeg [2019/11/30 18:06] – [Final rendering (re-encoding)] niccolo | doc:appunti:linux:video:ffmpeg [2023/04/18 12:51] – [ffmpeg: leggere la sequenza di VOB da un DVD] niccolo | ||
---|---|---|---|
Line 271: | Line 271: | ||
^ Video filter | ^ Video filter | ||
^ Basic x264 | Preset: **slow** (or less), Tuning: **film**, Profile: **High**, IDC Level: **Auto** | | ^ Basic x264 | Preset: **slow** (or less), Tuning: **film**, Profile: **High**, IDC Level: **Auto** | | ||
- | ^ Video encoding | + | ^ Video encoding |
^ Audio codec | < | ^ Audio codec | < | ||
^ Audio bitrate | ^ Audio bitrate | ||
- | We can use **Avidemux** to make the final rendering (re-encoding). For a **comman | + | We can use **Avidemux** to make the final rendering (re-encoding). For a **command |
- | ==== AVC (x264) is better than ASP (xvid4) ==== | + | <code bash> |
+ | #!/bin/sh | ||
+ | TITLE=" | ||
+ | ffmpeg \ | ||
+ | -i " | ||
+ | -i ' | ||
+ | -map ' | ||
+ | -metadata title=" | ||
+ | -metadata: | ||
+ | -metadata: | ||
+ | -filter:v " | ||
+ | -vcodec ' | ||
+ | -acodec copy \ | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====== Re-encoding with tonal correction ====== | ||
+ | |||
+ | We had some video clips recorded with an **SJCAM Sj8 Pro** camera with a **bad color balance and saturation** due some bad tables [[..: | ||
+ | |||
+ | The video clips were **extracted from the original MP4 container** as **[[wp> | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/sh | ||
+ | # | ||
+ | # Re-encode video clips in MPEG transport stream (MPEG-TS) format applying | ||
+ | # some saturation and gamma correction. | ||
+ | # | ||
+ | # saturation: | ||
+ | # gamma_{r|g|b} | ||
+ | |||
+ | INPUT=" | ||
+ | OUTPUT=" | ||
+ | EQ_FILTER=" | ||
+ | |||
+ | # Produces MPEG segments like the ones produced by the SJCAM SJ8Pro: | ||
+ | ffmpeg -i " | ||
+ | -vf " | ||
+ | -codec:v libx264 \ | ||
+ | -preset veryslow -profile:v main -level:v 4.2 -pix_fmt yuvj420p \ | ||
+ | -x264-params ' | ||
+ | -keyint_min 8 -brand avc1 -f 3gp \ | ||
+ | -bsf:v h264_mp4toannexb -f mpegts \ | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | The gamma correction for the three RGB channels was determined with the GIMP, using the //Colors// => //Levels// => //Pick the gray point for all channels// tool. The use of MPEG-TS clips allowed the montage of the final video by just concatenating them. | ||
+ | |||
+ | ===== AVC (x264) is better than ASP (xvid4) | ||
See this page: **[[https:// | See this page: **[[https:// | ||
Line 385: | Line 434: | ||
</ | </ | ||
- | the CSV format can be controlled by several options, e.g. if you want to know the key for each filed use: | + | the CSV format can be controlled by several options, e.g. if you want to print each field as a **key=val** pair, use: |
< | < | ||
Line 471: | Line 520: | ||
</ | </ | ||
+ | ====== Problem in MKV Remux ====== | ||
- | ====== Doppiaggio | + | It seems there is a bug in ffmpeg **[[https:// |
- | Per doppiare un video sostitutendo o mixando l' | + | This was the first try command line: |
- | + | ||
- | Per alcuni suggerimenti vedere il paragrafo sull' | + | |
- | ===== Estrazione traccia audio originale ===== | + | |
- | + | ||
- | La traccia audio originale verrà usata come riferimento per allineare i brani musicali da abbinare al video. | + | |
- | + | ||
- | **ATTENZIONE** alla conversione del file in formato WAV: controllare con '' | + | |
< | < | ||
- | ffmpeg -i video.mp4 -vn -c:a copy audio.m4a | + | # The resulting video is broken. |
- | ffmpeg | + | ffmpeg -i input_file1.mkv -i input_file2.mkv \ |
+ | | ||
+ | -map ' | ||
+ | | ||
+ | output_file.mkv | ||
</ | </ | ||
- | ===== Conversione dei brani audio ===== | + | The workaround was to extract each individual stream, and mux then together: |
- | + | ||
- | Per importare in Ardour i brani musicali vanno convertiti in WAV quelli non direttamente supportati (es. i file MP3 e le tracce M4A solitamente estratte dai video MP4). Per questo si può utilizzare **sox** (dall' | + | |
< | < | ||
- | sox file.mp3 file.wav | + | ffmpeg -i input_file1.mkv -map 0:v:0 -codec:v copy input-v_env.mkv |
+ | ffmpeg -i input_file1.mkv -map 0:a:0 -codec:a copy input-a_ita.mkv | ||
+ | ffmpeg -i input_file2.mkv -map 0:a:0 -codec:a copy input-a_eng.mkv | ||
+ | ffmpeg -i input_file2.mkv -map 0:s:0 -codec:s copy input-s_eng.mkv | ||
+ | ffmpeg \ | ||
+ | -i input-v_env.mkv \ | ||
+ | -i input-a_ita.mkv \ | ||
+ | -i input-a_eng.mkv \ | ||
+ | -i input-s_eng.mkv \ | ||
+ | -codec:v copy -codec:a copy -codec:s copy \ | ||
+ | -map ' | ||
+ | output_file.mkv | ||
</ | </ | ||
- | ===== Manipolazione | + | ====== ffmpeg: leggere la sequenza |
- | Con Ardour si inizia un **nuovo progetto**, impostare **48 kHz, 32 bit float, stereo**, che sono i parametri che vanno per la maggiore nei video MP4 in alta risoluzione. Quando il progetto | + | Nella directory |
- | Con Ardour si **importano** le varie **tracce musicali** (menu //Session// => //Import//). Conviene scegliere il **mapping one track per file**, altrimenti il canale destro e sinistro vengono importati | + | In teoria è sufficiente concatenare i file in un solo file destinazione e quindi trattarlo come un normale file audio/video. Tuttavia è possibile indicare i singoli |
- | Attenzione al **fader** di ogni traccia: se per caso viene spostato con il mouse, fare **Ctrl-click** per resettarlo al **valore predefinito di 0 dB**. | + | <code bash> |
+ | SOURCE=" | ||
+ | ffmpeg | ||
+ | </ | ||
- | {{..:ardour: | + | ====== ffmpeg: impostare un ritardo sui sottotitoli durante il muxing ====== |
- | Ogni **traccia** può essere manipolata separatamente | + | Se un flusso di sottotitoli |
- | === Spostare === | + | <code bash> |
+ | ffmpeg -i video-stream.mkv -i audio-stream.mkv -itsoffset 44.5 -i subtitles-stream.mkv ... | ||
+ | </ | ||
- | === Tagliare un pezzo === | + | In generale dovrebbe essere possibile scoprire l' |
- | * Strumento forbici | + | < |
- | * Zoom opportuno | + | [mpeg @ 0x55f98bb2c6c0] New subtitle stream 0:7 at pos: |
- | * Click sul punto: taglia immediatamente la traccia | + | </code> |
- | * Strumento selezione, click sul pezzo da togliere, menu //Region// => //Remove// | + | |
- | === Bloccare una singola regione | + | ====== |
- | + | ||
- | * Dopo averla selezionata, | + | |
- | + | ||
- | === Fade in/out === | + | |
- | + | ||
- | * Con lo strumento "Grab mode" cliccare una regione | + | |
- | * Trascinare il quadretto che appare all' | + | |
- | + | ||
- | === Esportare tutto il lavoro in WAV === | + | |
- | * //Session// => //Export// => //Export to Audio File(s)// | + | Vedere la pagina dedicata: **[[ardour_dubbing]]**. |
- | * **File formats**: impostare **WAV 16 bit, 48 KHz**. Eventualmente si può abilitare il **Normalize**, | + | |
- | * **Time Span**: Controllare che sia pari alla lunghezza originale. Se c'è qualcosa di troppo aggiustare il tag **end** nella barra **Location markers**. | + | |
- | * **Channels**: | + |
doc/appunti/linux/video/ffmpeg.txt · Last modified: 2023/11/13 11:24 by niccolo