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 [2021/11/17 00:13] andihowto:ffmpeg [2026/07/26 22:17] (current) – external edit 127.0.0.1
Line 1: Line 1:
-ffmpeg+ffmpeg
  
 Siehe auch [[transcoding]] für Realtime-Stream-Transcoding-Kommandos Siehe auch [[transcoding]] für Realtime-Stream-Transcoding-Kommandos
  
-== repo+## repo
  
 stretch stretch
Line 14: Line 14:
  
  
-== compiling+## compiling
 <code>apt-get build-dep ffmpeg yasm libmp3lame-dev libx264-dev libvpx-dev libvorbis-dev libopus-dev</code> <code>apt-get build-dep ffmpeg yasm libmp3lame-dev libx264-dev libvpx-dev libvorbis-dev libopus-dev</code>
-=== für Debian+### für Debian
 debian multimedia einbinden (falls noch nicht passiert) debian multimedia einbinden (falls noch nicht passiert)
 <code>deb http://www.deb-multimedia.org wheezy main non-free <code>deb http://www.deb-multimedia.org wheezy main non-free
Line 36: Line 36:
 make install </code> make install </code>
  
-== HD-Master mit Loudnorm+## HD-Master mit Loudnorm
 <code> <code>
 ffmpeg -y \ ffmpeg -y \
Line 55: Line 55:
 </code> </code>
  
-=== HD-Master mit Loudnorm, Pause rausschneiden+### HD-Master mit Loudnorm, Pause rausschneiden
  - Zeitstempel = *Sekunden.Frames*  - Zeitstempel = *Sekunden.Frames*
  - -t gibt Duration an, nicht Ende!  - -t gibt Duration an, nicht Ende!
Line 79: Line 79:
 </code> </code>
  
-== encoding snippets+## encoding snippets
  
-=== H264/AAC/Stereo+### H264/AAC/Stereo
  
 <code> <code>
Line 93: 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 99: Line 99:
 **Videofilter:** ''hqdn3d'' for denoising, ''yadif'' for deinterlacing. If both, combine them with a comma.  **Videofilter:** ''hqdn3d'' for denoising, ''yadif'' for deinterlacing. If both, combine them with a comma. 
  
-=== H264/AAC HQ+### H264/AAC HQ
  
 <code> <code>
Line 106: 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>
  
 **Videofilter:** ''hqdn3d'' for denoising, ''yadif'' for deinterlacing. If both, combine them with a comma.  **Videofilter:** ''hqdn3d'' for denoising, ''yadif'' for deinterlacing. If both, combine them with a comma. 
-=== WebM+### WebM
  
 <code>#!/bin/bash <code>#!/bin/bash
Line 133: Line 133:
   -aspect  16:9  -f  webm $target </code>   -aspect  16:9  -f  webm $target </code>
  
-=== FullHD+### FullHD
  
 Die Bitraten sind für Konferenz-Content (wenig Bewegung) in SD 16:9 (1024x576) getestet. Für HD-Content (1920x1080) haben wir beide Bitraten auf -maxrate:0 5000k gesetzt. Die Bitraten sind für Konferenz-Content (wenig Bewegung) in SD 16:9 (1024x576) getestet. Für HD-Content (1920x1080) haben wir beide Bitraten auf -maxrate:0 5000k gesetzt.
  
-=== WebCut LoRes MP4+### WebCut LoRes MP4
  
  
Line 161: Line 161:
  
  
-== one input, multiple format outputs +## one input, multiple format outputs
  
 1. h264/aac flv rtmp output 1. h264/aac flv rtmp output
Line 173: Line 173:
  
  
-== Translated Transcoding+## Translated Transcoding
  
 <code> <code>
Line 180: Line 180:
  
  
-== Audiospur via Backup Audioaufnahme reparieren und in MP4 packen+## Audiospur via Backup Audioaufnahme reparieren und in MP4 packen
  
 Sprache deu-backup im Tracker anlegen. Sprache deu-backup im Tracker anlegen.
Line 210: Line 210:
  
  
-== Audiospur(en) und Videospur vertauscht+## Audiospur(en) und Videospur vertauscht
 <code> <code>
 ffmpeg -i 5115-hd-broken.mp4 -map 0:v -map 0:a -c copy -map_metadata 0 5115-hd.mp4 ffmpeg -i 5115-hd-broken.mp4 -map 0:v -map 0:a -c copy -map_metadata 0 5115-hd.mp4
Line 218: Line 218:
  
  
-== audio channel mapping / repair+## audio channel mapping / repair
  
 https://trac.ffmpeg.org/wiki/AudioChannelManipulation https://trac.ffmpeg.org/wiki/AudioChannelManipulation
  
  
 +### mono mixdown
  
-=== silent fix+  ffmpeg -i 27-hd-orig.mp4 -codec:v copy -map_metadata 0 -ac 1 -ab 128k 27-hd.mp4 
 + 
 + 
 +### silent fix
 <code> <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; 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;
Line 237: Line 241:
  
  
-== metadata fix+## metadata fix
  
-=== map metadata and fix spezific entry+### map metadata and fix specific entry
  
 <code> <code>
 ffmpeg -i br0ken_licence/$file \ ffmpeg -i br0ken_licence/$file \
   -map_metadata 0 \   -map_metadata 0 \
-  -metadata:s:a:0 LICENSE="Licensed to the public under https://creativecommons.org/licenses/by/2.0/de/ - http://media.ccc.de" \+  -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   -c:a copy $file
 </code> </code>
  
-=== copy metadata from another file+### copy metadata from another file
  
 <code> <code>
Line 254: Line 258:
 </code> </code>
  
-=== Pause rausschneiden+### Pause rausschneiden
 Pause von 3840s = 1h04m00s Pause von 3840s = 1h04m00s
 bis 4691s = 1h18m11s bis 4691s = 1h18m11s
Line 269: Line 273:
          
  
-=== Icecast-Audio mit ffmpeg+### Icecast-Audio mit ffmpeg
  
     ffmpeg -re -i … -map 0:a -c:a mp3 -f mp3 \     ffmpeg -re -i … -map 0:a -c:a mp3 -f mp3 \
Line 279: Line 283:
         icecast://source:…@live.ber.c3voc.de:8000/foo.mp3         icecast://source:…@live.ber.c3voc.de:8000/foo.mp3
    
-=== Geschnittenes Camera MTS mit Backup Ton zu Final MP4+### Geschnittenes Camera MTS mit Backup Ton zu Final MP4
  
   ffmpeg -analyzeduration 20000000 -i video-cut.mov \   ffmpeg -analyzeduration 20000000 -i video-cut.mov \
Line 293: Line 297:
   -f mp4 -metadata title=<TITEL> -metadata:s:a:0 language=deu -metadata:s:a:1 language=backup encoded/video.mp4   -f mp4 -metadata title=<TITEL> -metadata:s:a:0 language=deu -metadata:s:a:1 language=backup encoded/video.mp4
  
-== Poster Image + Audio zu Video+## Poster Image + Audio zu Video
  
 https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images#Addingaudio https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images#Addingaudio
Line 322: Line 326:
     ffmpeg -t 60 -loop 1 -i 0-pause.png  -c:v libx264 -tune stillimage -pix_fmt yuv420p -shortest -map 0:v -f mpegts pause.ts     ffmpeg -t 60 -loop 1 -i 0-pause.png  -c:v libx264 -tune stillimage -pix_fmt yuv420p -shortest -map 0:v -f mpegts pause.ts
  
-== Streamen von einer USB Webcam (720p no audio)+## Streamen von einer USB Webcam (720p no audio)
 <code> <code>
 ffmpeg2theora /dev/video1 -f video4linux2 -x 1280 -y 720 -F 30 -v 10 --pp fd --noaudio -o - | oggfwd <icecast ip> <port> <pw> /<mountpoint> ffmpeg2theora /dev/video1 -f video4linux2 -x 1280 -y 720 -F 30 -v 10 --pp fd --noaudio -o - | oggfwd <icecast ip> <port> <pw> /<mountpoint>
 </code> </code>
  
-== HLS streaming+## HLS streaming
 <code> <code>
 ffmpeg -i - -filter:v yadif -c:v dvvideo -c:a copy -f dv - | \ ffmpeg -i - -filter:v yadif -c:v dvvideo -c:a copy -f dv - | \
Line 345: Line 349:
 </code> </code>
  
-== Facebook Live-Streaming+## Facebook Live-Streaming
  
 Facebook will zwingend 720p, 30 fps und eine i-Frame-Intervall von 2 Sekunden bei max. 4000k Bitrate. Audio darf nur 44100KHz sein (Stereo ist aber erlaubt). Facebook will zwingend 720p, 30 fps und eine i-Frame-Intervall von 2 Sekunden bei max. 4000k Bitrate. Audio darf nur 44100KHz sein (Stereo ist aber erlaubt).
Line 362: Line 366:
  
  
-== Periscope Live-Streaming+## Periscope Live-Streaming
  
 Periscope Producer will [[https://help.pscp.tv/customer/en/portal/articles/2600293-what-is-periscope-producer|laut Anleitung]] zwingend 720p (stellt sich raus: sollen sogar nur 540p sein), 30 fps und eine i-Frame-Intervall von 3 Sekunden (2 sind besser und gehen auch) bei max. 4000k Bitrate. Audio darf nur 44100KHz sein (Stereo ist aber erlaubt). Periscope Producer will [[https://help.pscp.tv/customer/en/portal/articles/2600293-what-is-periscope-producer|laut Anleitung]] zwingend 720p (stellt sich raus: sollen sogar nur 540p sein), 30 fps und eine i-Frame-Intervall von 3 Sekunden (2 sind besser und gehen auch) bei max. 4000k Bitrate. Audio darf nur 44100KHz sein (Stereo ist aber erlaubt).
Line 370: Line 374:
 </code> </code>
  
-== ffmpeg h264 encoding+## ffmpeg h264 encoding
  
 <code> <code>
Line 385: Line 389:
 </code> </code>
  
-== Timestamp Stream overlay+## Timestamp Stream overlay
 localtime ffmpeg newest standard localtime ffmpeg newest standard
 <code> <code>
Line 397: Line 401:
 </code> </code>
  
-== Konvertiere externe Video-Dateien zu mpeg-Segmente die der Tracker versteht+## Konvertiere externe Video-Dateien zu mpeg-Segmente die der Tracker versteht
  
 In unserem [[https://github.com/voc/scripts/|scripts]]-Repositorie gibt es ein Skript [[https://github.com/voc/scripts/blob/master/camera_recordings_to_segments/cam2seg.sh|cam2seg.sh]] welches alle Dateien in einem Ordner in Segmente konvertiert, welche der Tracker verstehen kann. Das Skript bitte einmal ohne Argmuente aufrufen für weitere Instruktionen: ''sh cam2seg.sh''. In unserem [[https://github.com/voc/scripts/|scripts]]-Repositorie gibt es ein Skript [[https://github.com/voc/scripts/blob/master/camera_recordings_to_segments/cam2seg.sh|cam2seg.sh]] welches alle Dateien in einem Ordner in Segmente konvertiert, welche der Tracker verstehen kann. Das Skript bitte einmal ohne Argmuente aufrufen für weitere Instruktionen: ''sh cam2seg.sh''.
  
-== relaying a HLS stream to our cdn ( and fix most of the brokyness it comes with from "professional" CDNs )+## relaying a HLS stream to our cdn ( and fix most of the brokyness it comes with from "professional" CDNs )
 <code> <code>
 ffmpeg -headers 'User-Agent: bar'$'\r\n' -i http://yourBrokenCDN.com/stupidfilename.m3u8  -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2  -bsf:a aac_adtstoasc -f flv rtmp://localhost:1935/test/q1   ffmpeg -headers 'User-Agent: bar'$'\r\n' -i http://yourBrokenCDN.com/stupidfilename.m3u8  -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2  -bsf:a aac_adtstoasc -f flv rtmp://localhost:1935/test/q1  
Line 412: Line 416:
 streamlink -l debug https://www.youtube.com/watch?v=DeQkjJ9JJTI 720p --player="ffmpeg -c copy -bsf:a aac_adtstoasc -f flv rtmp://127.0.0.1:1935/live/irgendwas -i" streamlink -l debug https://www.youtube.com/watch?v=DeQkjJ9JJTI 720p --player="ffmpeg -c copy -bsf:a aac_adtstoasc -f flv rtmp://127.0.0.1:1935/live/irgendwas -i"
 </code> </code>
-== HLS Streamdump als Backup, gleich in Schnipseln+## HLS Streamdump als Backup, gleich in Schnipseln
  
 (Natürlich ist das dann H.264 in TS statt MPEG2 in TS, aber das sollte trotzdem alles funktionieren) (Natürlich ist das dann H.264 in TS statt MPEG2 in TS, aber das sollte trotzdem alles funktionieren)
Line 420: Line 424:
 </code> </code>
  
-== Blur eines Bildausschnitts (Rechteckiges Fenster der Größe $XSIZE und $YSIZE, mit Offset $XOFFSET und $YOFFSET, alles in Pixeln)+## Blur eines Bildausschnitts (Rechteckiges Fenster der Größe $XSIZE und $YSIZE, mit Offset $XOFFSET und $YOFFSET, alles in Pixeln)
  
 <code> <code>
Line 426: Line 430:
 </code> </code>
  
-== Schwarze Box / Black Box über einen Bildausschnitt legen+## Schwarze Box / Black Box über einen Bildausschnitt legen
  
 50 = Box-Breite, 40 = Box-Höhe, 5 = Box-X-Position, 4 = Box-Y-Position 50 = Box-Breite, 40 = Box-Höhe, 5 = Box-X-Position, 4 = Box-Y-Position
Line 434: Line 438:
 </code> </code>
  
-== Filter konkatenieren, hier: 2 Schwarze Boxen / Black Boxes über einen Bildausschnitt legen+## Filter konkatenieren, hier: 2 Schwarze Boxen / Black Boxes über einen Bildausschnitt legen
  
 Box 1 (z.B. Laufschrift-Balken) Box 1 (z.B. Laufschrift-Balken)
Line 446: Line 450:
 </code> </code>
  
-== RGB/YUV Blödsinn+## RGB/YUV Blödsinn
  
 Das ist alles sehr verwirrend, einfach beides probieren und das nehmen, was richtig aussieht. Das ist alles sehr verwirrend, einfach beides probieren und das nehmen, was richtig aussieht.
Line 460: Line 464:
 </code> </code>
  
-== AV sync test using ffmpeg / ffplay+## AV sync test using ffmpeg / ffplay
  
 This might be useful to find A/V drifting behavior in the production chain. Simply use this as the generator. For use as a source for our streaming relay: This might be useful to find A/V drifting behavior in the production chain. Simply use this as the generator. For use as a source for our streaming relay:
Line 480: Line 484:
 </code> </code>
  
-== ffmpeg only multiview+## ffmpeg only multiview
 <code> <code>
 #/bin/bash #/bin/bash
Line 540: Line 544:
 exit exit
 </code> </code>
-== DASH encoding +## DASH encoding 
-=== VOD encoding+### VOD encoding
  
 um static files in mehreren bitraten/aufloesungen nach DASH zu konvertieren. um static files in mehreren bitraten/aufloesungen nach DASH zu konvertieren.
Line 617: Line 621:
 </code> </code>
  
-=== screen capture and stream ===+### screen capture and stream
  
 <code> <code>
  • howto/ffmpeg.1637108007.txt.gz
  • Last modified: 2021/11/17 00:13
  • by andi