Benutzer-Werkzeuge

Webseiten-Werkzeuge


ffmpeg

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

ffmpeg [2024/07/19 00:42]
127.0.0.1 Externe Bearbeitung
ffmpeg [2025/09/06 11:20] (aktuell)
jango [Links]
Zeile 1: Zeile 1:
 +=====Stream=====
  
 +Mit [[vlc|VLC]] kann man auch direkt streamen.
 +
 +<code>
 +
 +// save to file
 +ffmpeg.exe -i http://example.com/playlist.m3u8 -vcodec libx264 -acodec copy -f mp4 record.mp4 
 +
 +// restream to hls
 +ffmpeg.exe -re -i manifest.m3u8 -f hls -hls_time 1 -hls_list_size 5 -hls_flags delete_segments live.m3u8
 +ffmpeg -i manifest.m3u8 -f ssegment -strftime 1 -segment_list live.m3u8 -segment_time 10 live_%%Y%%m%%d%%H%%M%%S.ts
 +
 +// restream to dash
 +ffmpeg -i manifest.m3u8 -f dash live.mpd
 +
 +// restream to rtmp
 +ffmpeg.exe -re -i test.mp4 -vcodec copy -acodec copy -f flv rtmp://localhost:1935/live/test
 +ffmpeg -re -i file.mp4 -vcodec libx264 -f flv rtmp://live.twitch.tv/app/<STREAM KEY>
 +
 +//restream to hls
 +ffmpeg -re -i https://cnn-cnninternational-1-de.samsung.wurl.com/manifest/playlist.m3u8 -hls_time 1 -hls_list_size 3 -hls_flags delete_segments -s 1366x768 -strict -2 -ab 128k -ar 44100 c:\xampp\htdocs\playlist.m3u8
 +
 +// find recording devices
 +ffmpeg -list_devices true -f dshow -i dummy
 +// list recording device options
 +ffmpeg -f dshow -list_options true -i video="Integrated Camera"
 +// start recording
 +ffmpeg -f dshow -s 320x240 -r 30 -vcodec mjpeg -i video="Integrated Camera" output.mp4
 +
 +// stream desktop
 +ffmpeg -f gdigrab -r 30 -i desktop -c:v libx264 -g 250 -c:a libfdk_aac -ac 2 -hls_time 1 -hls_list_size 4 -hls_wrap 8 -s 1366x768 -strict -2 -ab 128k -ar 44100 D:/xampp/htdocs/playlist.m3u8
 +
 +// stream image
 +ffmpeg.exe -loop 1 -i test.png -vcodec libx264 -acodec copy -vf "drawtext=fontsize=340:fontcolor=white:font=SansSerif:textfile='xxx.txt':reload=1:x=(w-text_w)/2:y=(h-text_h)/2" -f flv rtmp://
 +</code>
 +
 +=====Convert=====
 +
 +https://bytescout.com/blog/2016/12/ffmpeg-command-lines-convert-various-video-formats.html
 +
 +<code>
 +
 +ffmpeg -i file.mp4 file.mp3
 +
 +// mp4 to flv
 +ffmpeg -i v.mp4 -c:v libx264 -crf 19 v.flv
 +
 +// avi to gif
 +FFmpeg –i – v.avi v.gif
 +
 +// mp4 to ts
 +ffmpeg -i test.mp4 -bsf:v h264_mp4toannexb -codec copy output.ts
 +
 +// mix png and mp3 to mp4
 +ffmpeg -loop 1 -framerate 2 -i test.png -i test.mp3 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p test.mp4
 +
 +ffmpeg -i video.mp4 -i overlay.png -filter_complex "[0:v][1:v] overlay=0:0" -c:a copy output.mp4
 +
 +// extract frames
 +ffmpeg -i test.mp4 frame_%05d.bmp
 +
 +// extract all frames from between 1 and 5 seconds, and also between 11 and 15 seconds:
 +ffmpeg -i in.mp4 -vf select='between(t,1,5)+between(t,11,15)' -vsync 0 out%d.png
 +
 +</code>
 +
 +=====Modify=====
 +
 +<code>
 +
 +// extract metadata
 +ffmpeg -i in.mp3 -f ffmetadata metadata.txt
 +
 +// add metadata
 +ffmpeg -i in.mp3 -acodec copy -metadata title="t" -metadata artist="a" -metadata album="a" out.mp3
 +
 +// remove audio
 +ffmpeg in.mp4 -an out.mp4
 +
 +// remove video
 +ffmpeg -i in.mp4 -vn out.mp3
 +
 +// increase volume to 150%
 +ffmpeg -i in.mp4 -filter:a "volume=1.5" out.mp4
 +
 +// decrease volume by 50%
 +ffmpeg -i in.mp4 -filter:a "volume=0.5" out.mp4
 +
 +//deinterlace
 +ffmpeg -i in.mp4 -vf yadif out.mp4
 +
 +//replace the first 90 seconds of audio with silence
 +ffmpeg -i in.mp4 -vcodec copy -af "volume=enable='lte(t,90)':volume=0" out.mp4
 +
 +//replace all audio between 1'20" and 1'30" with silence:
 +ffmpeg -i in.mp4 -vcodec copy -af "volume=enable='between(t,80,90)':volume=0" out.mp4
 +
 +// rotate 2x 90' clockwise
 +// 0 = 90CounterCLockwise and Vertical Flip (default)
 +// 1 = 90Clockwise
 +// 2 = 90CounterClockwise
 +// 3 = 90Clockwise and Vertical Flip
 +ffmpeg -i in.mp4 -vf "transpose=1, transpose=1" out.mp4
 +
 +// flip vertical/horizontal
 +ffmpeg -i in.mp4 -vf "hflip,vflip" out.mp4
 +
 +//scale
 +ffmpeg -i in.mp4 -vf scale=1024:789 out.mp4
 +ffmpeg -i in.mp4 -s 1280x720 -c:a copy out.mp4
 +
 +// overlay, 1st input on layer 0, 2nd input on layer 1
 +ffmpeg -i in.mp4 -i overlay.png -filter_complex "[0:v][1:v] overlay=100:100" out.mp4
 +
 +ffmpeg -i in.mp4 -i overlay.png -filter_complex "overlay=x=2160-800:y=3840-400" out.mp4
 +
 +// cut out a clip, start at 0 seconds and record 3 seconds long
 +ffmpeg -i in.mp4 -ss 0 -c copy -t 3 out.mp4
 +ffmpeg -i in.mp4 -ss 00:00:00 -c copy -t 00:00:03 out.mp4
 +
 +// cut out a clip, start at 00:00:00 seconds and record until 00:01:30
 +ffmpeg -i in.mp4 -ss 00:00:00 -to 00:01:30 -c:v copy -c:a copy out.mp4
 +
 +// make transparent background
 +ffmpeg -i in.png -vf colorkey=white:0.3:0.5 out.png
 +
 +//change color (lt, lte, eq, gte, gt)
 +ffmpeg -i logo.png -vf "yadif,format=rgb24,lutrgb=r='if(gt(val,128),255,val)':g='if(gt(val,128),255,val)':b='if(gt(val,128),255,val)'" out.png
 +
 +// 0:0:0:0 == rgba
 +ffmpeg -i logo.png -filter_complex "colorchannelmixer=0:0:1:0:0:1:0:0:1:0:0:0" out.png
 +
 +//Delay video by 3.84 seconds:
 +ffmpeg -i in.mp4 -itsoffset 3.84 -i in.mp4 -map 1:v -map 0:a -vcodec copy -acodec copy out.mp4
 +
 +//Delay audio by 3.84 seconds:
 +ffmpeg -i in.mp4 -itsoffset 3.84 -i in.mp4 -map 0:v -map 1:a -vcodec copy -acodec copy out.mp4
 +
 +// demuxing
 +// file.txt example
 +file 'in1.mp4'
 +file 'in2.mp4'
 +file 'in3.mp4'
 +file 'in4.mp4'
 +// then run
 +ffmpeg -f concat -i file.txt -c copy out.mp4
 +
 +//copy the video from in0.mp4 and audio from in1.mp4:
 +ffmpeg -i in0.mp4 -i in1.mp4 -c copy -map 0:0 -map 1:1 -shortest out.mp4
 +
 +</code>
 +
 +=====Links=====
 +
 +  * [[https://www.gyan.dev/ffmpeg/builds|Download]]
 +  * [[https://github.com/FutaAlice/ffmpeg-static-libs|Static lib binaries]]
 +  * [[https://github.com/leandromoreira/ffmpeg-libav-tutorial|LibAV Tutorial]]
 +  * [[https://ffmpeg.org/documentation.html|Docs]]
 +  * [[https://spielwiese.la-evento.com/hokuspokus/|Beispiele]]
 +  * [[https://www.youtube.com/watch?v=6uB65PdasQI|Learn FFMPEG - Youtube]]
ffmpeg.txt · Zuletzt geändert: 2025/09/06 11:20 von jango