howto:ffmpeg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howto:ffmpeg [2020/12/06 17:22] – ffmpeg renamed to howto:ffmpeg andihowto:ffmpeg [2023/06/11 00:58] (current) – [audio channel mapping / repair] andi
Line 36: Line 36:
 make install </code> make install </code>
  
-== audio channel mapping doku +== HD-Master mit Loudnorm
- +
-https://trac.ffmpeg.org/wiki/AudioChannelManipulation +
- +
- +
- +
-== silent fix+
 <code> <code>
-ffmpeg -ar 48000 -acodec pcm_s16le -f s16le -ac 2 -i <( dd if=/dev/zero ) --i not_silent/$file  -t 10.0 -c:v copy $file+ffmpeg -y \ 
-</code> +-i /video/intros/XXX/intro.ts -analyzeduration 20000000 \ 
- +-ss 1858.48 -t 3550.88 -i /video/fuse//XXX/YYY/ZZZ/uncut.ts -analyzeduration 20000000 \ 
-Oder "schöner" und ohne knacken:+-i /video/intros/XXX/outro.ts \ 
 +-filter_complex ' 
 +  [0:a:0] loudnorm=i=-16:print_format=summary [norm-0-0]; 
 +  [1:a:0] loudnorm=i=-16:print_format=summary [norm-1-0]
 +  [2:a:0] loudnorm=i=-16:print_format=summary [norm-2-0];
  
-<code> +  [0:v:0] [norm-0-0] [1:v:0] [norm-1-0] [2:v:0] [norm-2-0] concat=n=3:v=1:a=1 [vd] [audio0_mix]; 
-ffmpeg -i not_silent/$file -filter_complex "aevalsrc=c=2c:s=48000:0|0 [a]-map 0:v -c:v copy -map "[a]-c:a $audiocodec -shortest $outputfile+  [vd] yadif=mode=0:parity=0, hqdn3d [v] 
 +' -analyzeduration 20000000/ 
 +-map '[v]' -c:v:0 libx264 -pix_fmt yuv420p -crf:0 23 -profile:0 high -level:0 4.1 
 +-map '[audio0_mix]-c:a:0 aac -b:a:0 192k -ar:a:0 48000 \ 
 +-aspect 16:9 -movflags faststart -f mp4 /video/tmp/XXX/ZZZ-hd.mp4
 </code> </code>
-$audiocodec z.B. mp2 bei Intros 
-== metadata fix 
  
-=== map metadata and fix spezific entry+=== HD-Master mit Loudnorm, Pause rausschneiden 
 + - Zeitstempel = *Sekunden.Frames* 
 + - -t gibt Duration an, nicht Ende!
  
 <code> <code>
-ffmpeg -i br0ken_licence/$file +ffmpeg -y \ 
-  -map_metadata 0 +-i /video/intros/XXX/intro.ts -analyzeduration 20000000 
-  -metadata:s:a:0 LICENSE="Licensed to the public under https://creativecommons.org/licenses/by/2.0/de/ - http://media.ccc.de" +-ss 1858.48 -t 3550.88 -i /video/fuse//XXX/YYY/ZZZ/uncut.ts -analyzeduration 20000000 
-  -c:a copy $file +-ss 1858.48 -t 3550.88 -i /video/fuse//XXX/YYY/ZZZ/uncut.ts -analyzeduration 20000000 \ 
-</code>+-i /video/intros/XXX/outro.ts \ 
 +-filter_complex ' 
 +  [0:a:0] loudnorm=i=-16:print_format=summary [norm-0-0]; 
 +  [1:a:0] loudnorm=i=-16:print_format=summary [norm-1-0]; 
 +  [2:a:0] loudnorm=i=-16:print_format=summary [norm-2-0]; 
 +  [3:a:0] loudnorm=i=-16:print_format=summary [norm-3-0];
  
-=== copy metadata from another file +  [0:v:0] [norm-0-0] [1:v:0] [norm-1-0] [2:v:0] [norm-2-0] [3:v:0] [norm-3-0] concat=n=4:v=1:a=1 [vd] [audio0_mix]; 
- +  [vd] yadif=mode=0:parity=0, hqdn3d [v] 
-<code> +' -analyzeduration 20000000/ 
-ffmpeg -i $metadata_source -i $video_source -map 1 -c copy -map_metadata $output_file+-map '[v]' -c:v:0 libx264 -pix_fmt yuv420p -crf:0 23 -profile:0 high -level:0 4.1 
 +-map '[audio0_mix]' -c:a:0 aac -b:a:192k -ar:a:0 48000 \ 
 +-aspect 16:9 -movflags faststart -f mp4 /video/tmp/XXX/ZZZ-hd.mp4
 </code> </code>
  
-== one input, multiple format outputs  
- 
-1. h264/aac flv rtmp output 
-2. theora/vorbis ogg output 
- 
-<code> 
-ffmpeg -re -i 29c3-5266-de-en-proximax_telex_flashproxy_h264.mp4 -threads 0 -pix_fmt yuv420p -profile:v baseline -preset fast -tune zerolatency -c:v libx264 -strict -2 -c:a aac \ 
--f flv rtmp://localhost:1935/stream/saal1 \ 
--map 0 -c:v libtheora -c:a libvorbis -f ogg - | oggfwd localhost 8000 … 
-</code> 
- 
-== Audiospur via Backup Audioaufnahme reparieren und in MP4 packen 
- 
-Sprache deu-backup im Tracker anlegen. 
-Nochmal neu rausrendern lassen. 
- 
-einzelne Audiopuren vor oder nach Auphnic so umwandeln das Audio-Schnitt Tool wie z.B. Reaper was damit anfangen kann: 
- 
-  ffmpeg -i 5100-hd-audio2-auphonic.m4a -vn -c:a copy -bsf:a aac_adtstoasc 5100-hd-audio2-auphonic-echt.m4a 
-  ffmpeg -i 5100-hd-audio2-auphonic.m4a -vn -c:a copy -bsf:a aac_adtstoasc 5100-hd-audio2-auphonic-echt.m4a 
- 
- 
-Fertige Audiospur in Reaper rausrechnen, z.B. als Flac 
- 
-Audiospur wieder in Vortrag MP4 einpacken: 
- 
-<code> 
-ffmpeg -threads 0 -i /video/encoded/fossgis16/5100-hd-primary-audio-only.mp4 -i 5100-audio-fixed.flac -map 0:0 -map 1:0 -map_metadata 0 -c:v copy -c:a:0 libfdk_aac -vbr 4 -ar:a:0 48000  -metadata:s:a:0 language=deu 5100-hd-fixed2.mp4  
-</code> 
- 
-Alte Version 
-<code> 
-ffmpeg -threads 0 -i 5100-hd.mp4  -i 5100-audio-fixed.flac -map 0:0 -map 1:0 -map_metadata 1 5100-hd-fixed.mp4 
-</code> 
- 
- 
-Anmerkung: Geht auch mit MTS Datei (Transportstream mit H264 Video) der so aus der Consumer-Kamera auf die SD Karte fällt. 
- 
-Siehe auch: https://trac.ffmpeg.org/wiki/AudioChannelManipulation 
-== Audiospur(en) und Videospur vertauscht 
-<code> 
-ffmpeg -i 5115-hd-broken.mp4 -map 0:v -map 0:a -c copy -map_metadata 0 5115-hd.mp4 
-</code> 
- 
-== Translated Transcoding 
- 
-<code> 
-ffmpeg -y -i rtmp://live.lan.c3voc.de/stream/mastermaster -aspect 16:9 -threads:0 0 -c:v libx264 -filter_complex '[0:v] yadif, scale=1920:1080 [v]; [0:a:0] pan=stereo|c0=FL [native]'  -map '[native]'  -map '[v]' -maxrate:v:0 2800k -bufsize:v:0 8192k -crf:0 18 -pix_fmt:0 yuv420p -profile:v:0 main -g:v:0 25 -preset:v:0 veryfast -ac 1 -y -f flv rtmp://live.lan.c3voc.de/push/master_translated_hd 
-</code> 
 == encoding snippets == encoding snippets
  
Line 133: Line 93:
   -metadata title="<title>" \   -metadata title="<title>" \
     -metadata album="<album>" \     -metadata album="<album>" \
-    -metadata copyright="Licensed to the public under http://creativecommons.org/licenses/by-sa/3.0/" \+    -metadata copyright="This work is licensed under a Creative Commons Attribution 4.0 International License. https://creativecommons.org/licenses/by/4.0/" \
   <output-file-name>   <output-file-name>
 </code> </code>
Line 146: Line 106:
   -c:a libfdk_aac -b:a 192k -aspect 16:9 -metadata title="<title>" \   -c:a libfdk_aac -b:a 192k -aspect 16:9 -metadata title="<title>" \
     -metadata album="<album>" \     -metadata album="<album>" \
-    -metadata copyright="Licensed to the public under http://creativecommons.org/licenses/by-sa/3.0/" \+    -metadata copyright="This work is licensed under a Creative Commons Attribution 4.0 International License. https://creativecommons.org/licenses/by/4.0/" \
     -f mp4 -movflags faststart <output-file-name>     -f mp4 -movflags faststart <output-file-name>
 </code> </code>
Line 198: Line 158:
  -c:a mp3 -b:a 32k -ar:a 22050 -f mp4 -movflags faststart \  -c:a mp3 -b:a 32k -ar:a 22050 -f mp4 -movflags faststart \
  /video/tmp/..../cut-101-proxy.mp4  /video/tmp/..../cut-101-proxy.mp4
 +</code>
 +
 +
 +== one input, multiple format outputs 
 +
 +1. h264/aac flv rtmp output
 +2. theora/vorbis ogg output
 +
 +<code>
 +ffmpeg -re -i 29c3-5266-de-en-proximax_telex_flashproxy_h264.mp4 -threads 0 -pix_fmt yuv420p -profile:v baseline -preset fast -tune zerolatency -c:v libx264 -strict -2 -c:a aac \
 +-f flv rtmp://localhost:1935/stream/saal1 \
 +-map 0 -c:v libtheora -c:a libvorbis -f ogg - | oggfwd localhost 8000 …
 +</code>
 +
 +
 +== Translated Transcoding
 +
 +<code>
 +ffmpeg -y -i rtmp://live.lan.c3voc.de/stream/mastermaster -aspect 16:9 -threads:0 0 -c:v libx264 -filter_complex '[0:v] yadif, scale=1920:1080 [v]; [0:a:0] pan=stereo|c0=FL [native]'  -map '[native]'  -map '[v]' -maxrate:v:0 2800k -bufsize:v:0 8192k -crf:0 18 -pix_fmt:0 yuv420p -profile:v:0 main -g:v:0 25 -preset:v:0 veryfast -ac 1 -y -f flv rtmp://live.lan.c3voc.de/push/master_translated_hd
 +</code>
 +
 +
 +== Audiospur via Backup Audioaufnahme reparieren und in MP4 packen
 +
 +Sprache deu-backup im Tracker anlegen.
 +Nochmal neu rausrendern lassen.
 +
 +einzelne Audiopuren vor oder nach Auphnic so umwandeln das Audio-Schnitt Tool wie z.B. Reaper was damit anfangen kann:
 +
 +  ffmpeg -i 5100-hd-audio2-auphonic.m4a -vn -c:a copy -bsf:a aac_adtstoasc 5100-hd-audio2-auphonic-echt.m4a
 +  ffmpeg -i 5100-hd-audio2-auphonic.m4a -vn -c:a copy -bsf:a aac_adtstoasc 5100-hd-audio2-auphonic-echt.m4a
 +
 +
 +Fertige Audiospur in Reaper rausrechnen, z.B. als Flac
 +
 +Audiospur wieder in Vortrag MP4 einpacken:
 +
 +<code>
 +ffmpeg -threads 0 -i /video/encoded/fossgis16/5100-hd-primary-audio-only.mp4 -i 5100-audio-fixed.flac -map 0:0 -map 1:0 -map_metadata 0 -c:v copy -c:a:0 libfdk_aac -vbr 4 -ar:a:0 48000  -metadata:s:a:0 language=deu 5100-hd-fixed2.mp4 
 +</code>
 +
 +Alte Version
 +<code>
 +ffmpeg -threads 0 -i 5100-hd.mp4  -i 5100-audio-fixed.flac -map 0:0 -map 1:0 -map_metadata 1 5100-hd-fixed.mp4
 +</code>
 +
 +
 +Anmerkung: Geht auch mit MTS Datei (Transportstream mit H264 Video) der so aus der Consumer-Kamera auf die SD Karte fällt.
 +
 +Siehe auch: https://trac.ffmpeg.org/wiki/AudioChannelManipulation
 +
 +
 +== Audiospur(en) und Videospur vertauscht
 +<code>
 +ffmpeg -i 5115-hd-broken.mp4 -map 0:v -map 0:a -c copy -map_metadata 0 5115-hd.mp4
 +</code>
 +
 +
 +
 +
 +== audio channel mapping / repair
 +
 +https://trac.ffmpeg.org/wiki/AudioChannelManipulation
 +
 +
 +=== mono mixdown
 +
 +  ffmpeg -i 27-hd-orig.mp4 -codec:v copy -map_metadata 0 -ac 1 -ab 128k 27-hd.mp4
 +
 +
 +=== silent fix
 +<code>
 +ffmpeg -ar 48000 -acodec pcm_s16le -f s16le -ac 2 -i <( dd if=/dev/zero ) -y -i not_silent/$file  -t 10.0 -c:v copy $file;
 +</code>
 +
 +Oder "schöner" und ohne knacken:
 +
 +<code>
 +ffmpeg -i not_silent/$file -filter_complex "aevalsrc=c=2c:s=48000:0|0 [a]" -map 0:v -c:v copy -map "[a]" -c:a $audiocodec -shortest $outputfile
 +</code>
 +$audiocodec z.B. mp2 bei Intros
 +
 +
 +== metadata fix
 +
 +=== map metadata and fix specific entry
 +
 +<code>
 +ffmpeg -i br0ken_licence/$file \
 +  -map_metadata 0 \
 +  -metadata:s:a:0 LICENSE="This work is licensed under a Creative Commons Attribution 4.0 International License. https://creativecommons.org/licenses/by/4.0/" \
 +  -c:a copy $file
 +</code>
 +
 +=== copy metadata from another file
 +
 +<code>
 +ffmpeg -i $metadata_source -i $video_source -map 1 -c copy -map_metadata 0 $output_file
 </code> </code>
  
Line 214: Line 272:
     " -map '[v]' -c:v:0 libx264 -pix_fmt yuv420p -bufsize:0 8192k -crf:0 20 -minrate:0 100k -maxrate:0 5000k -profile:0 main -level:0 4.0 -threads 8 -map '[a]' -c:a:0 libfdk_aac -b:a:0 192k -ac:a:0 1 -ar:a:0 48000 -aspect 16:9 -f mp4 50-hd-camonly-cut.mp4     " -map '[v]' -c:v:0 libx264 -pix_fmt yuv420p -bufsize:0 8192k -crf:0 20 -minrate:0 100k -maxrate:0 5000k -profile:0 main -level:0 4.0 -threads 8 -map '[a]' -c:a:0 libfdk_aac -b:a:0 192k -ac:a:0 1 -ar:a:0 48000 -aspect 16:9 -f mp4 50-hd-camonly-cut.mp4
          
-=== HD-Master mit Loudnorm 
-<code> 
-ffmpeg -y \ 
--i /video/intros/XXX/intro.ts -analyzeduration 20000000 \ 
--ss 1858.48 -t 3550.88 -i /video/fuse//XXX/YYY/ZZZ/uncut.ts -analyzeduration 20000000 \ 
--i /video/intros/XXX/outro.ts \ 
--filter_complex ' 
-  [0:a:0] loudnorm=i=-16:print_format=summary [norm-0-0]; 
-  [1:a:0] loudnorm=i=-16:print_format=summary [norm-1-0]; 
-  [2:a:0] loudnorm=i=-16:print_format=summary [norm-2-0]; 
  
-  [0:v:0] [norm-0-0] [1:v:0] [norm-1-0] [2:v:0] [norm-2-0] concat=n=3:v=1:a=1 [vd] [audio0_mix]; 
-  [vd] yadif=mode=0:parity=0, hqdn3d [v] 
-' -analyzeduration 20000000/ 
--map '[v]' -c:v:0 libx264 -pix_fmt yuv420p -crf:0 23 -profile:0 high -level:0 4.1 
--map '[audio0_mix]' -c:a:0 aac -b:a:0 192k -ar:a:0 48000 \ 
--aspect 16:9 -movflags faststart -f mp4 /video/tmp/XXX/ZZZ-hd.mp4 
-</code> 
- 
-=== HD-Master mit Loudnorm, Pause rausschneiden 
- - Zeitstempel = *Sekunden.Frames* 
- - -t gibt Duration an, nicht Ende! 
- 
-<code> 
-ffmpeg -y \ 
--i /video/intros/XXX/intro.ts -analyzeduration 20000000 \ 
--ss 1858.48 -t 3550.88 -i /video/fuse//XXX/YYY/ZZZ/uncut.ts -analyzeduration 20000000 \ 
--ss 1858.48 -t 3550.88 -i /video/fuse//XXX/YYY/ZZZ/uncut.ts -analyzeduration 20000000 \ 
--i /video/intros/XXX/outro.ts \ 
--filter_complex ' 
-  [0:a:0] loudnorm=i=-16:print_format=summary [norm-0-0]; 
-  [1:a:0] loudnorm=i=-16:print_format=summary [norm-1-0]; 
-  [2:a:0] loudnorm=i=-16:print_format=summary [norm-2-0]; 
-  [3:a:0] loudnorm=i=-16:print_format=summary [norm-3-0]; 
- 
-  [0:v:0] [norm-0-0] [1:v:0] [norm-1-0] [2:v:0] [norm-2-0] [3:v:0] [norm-3-0] concat=n=4:v=1:a=1 [vd] [audio0_mix]; 
-  [vd] yadif=mode=0:parity=0, hqdn3d [v] 
-' -analyzeduration 20000000/ 
--map '[v]' -c:v:0 libx264 -pix_fmt yuv420p -crf:0 23 -profile:0 high -level:0 4.1 
--map '[audio0_mix]' -c:a:0 aac -b:a:0 192k -ar:a:0 48000 \ 
--aspect 16:9 -movflags faststart -f mp4 /video/tmp/XXX/ZZZ-hd.mp4 
-</code> 
 === Icecast-Audio mit ffmpeg === Icecast-Audio mit ffmpeg
  
  • howto/ffmpeg.1607271749.txt.gz
  • Last modified: 2020/12/06 17:22
  • by andi