Skip to content

Instantly share code, notes, and snippets.

@kris-lab
Last active March 31, 2016 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kris-lab/28060a51c122b4da08b9 to your computer and use it in GitHub Desktop.
Save kris-lab/28060a51c122b4da08b9 to your computer and use it in GitHub Desktop.
ffmpeg benchmarking
# tested on Debian
# require ffmpeg@2.6.3 with --enable-libfreetype for drawtext extension
# ffmpeg streaming to ffserver feed
# file -> ffmpeg (playback) -> ffmpeg (add timestamp) -> ffmpeg (add timestamp) -> ffserver (FFM delivery)
ffmpeg -i your-file.mp4 -tune zerolatency -filter:v "setpts=1.0*PTS" -f nut pipe:1 \
| ffmpeg -re -i pipe:0 -vf "drawtext=expansion=normal:fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf:reload=1:textfile=test.txt: x=50: y=50: fontcolor=white" -tune zerolatency -f nut pipe:1 \
| ffmpeg -y -i pipe:0 -tune zerolatency http://ffserver-ip:7000/feed1.ffm
# ffmpeg client of ffserver stream
ffmpeg -rtsp_transport tcp -i rtsp://ffserver-ip:8544/live.mp4 -tune zerolatency -vf "drawtext=expansion=normal:fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf:reload=1:textfile=test.txt: x=50: y=70: fontcolor=white" output.mp4
# /etc/ffserver.conf
-------------------------------------------------------------------------------
HTTPPort 7000
HTTPBindAddress 0.0.0.0
RTSPPort 8544
RTSPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 100M
</Feed>
<Stream test1.mpg>
Feed feed1.ffm
Format mp2
AudioBitRate 32
AudioChannels 1
AudioSampleRate 44100
VideoBitRate 64
VideoFrameRate 24
VideoSize 480x360
VideoGopSize 12
Preroll 0
NoDefaults
</Stream>
<Stream live.mp4>
Feed feed1.ffm
Format rtp
BitExact
DctFastint
IdctSimple
VideoFrameRate 24
VideoSize 480x360
VideoBitRate 64
VideoGopSize 10
NoAudio
PreRoll 0
StartSendOnKey
MaxTime 10000
</Stream>
<Stream stat.html>
Format status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
</Stream>
<Redirect index.html>
URL http://www.ffmpeg.org/
</Redirect>
-------------------------------------------------------------------------------
# test.txt updater
# run this file with python
-------------------------------------------------------------------------------
import time
logfile = 'time.txt'
f = open(logfile, 'r+')
for i in range (0, 50000000):
time.sleep(0.05)
f.seek(0)
f.truncate(0)
f.write(str(time.time()))
f.flush()
f.close()
-------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment