Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

BKM: Collection of Useful FFmpeg Commands

xwu2 edited this page Dec 6, 2019 · 1 revision

Transcoding

  • Transcode raw yuv420 content to SVT-HEVC and mp4:
ffmpeg -f rawvideo -vcodec rawvideo -s 320x240 -r 30 -pix_fmt yuv420p -i test.yuv -c:v libsvt_hevc -y test.mp4
  • 1:N Transcoding:
ffmpeg -i input.h264 -vf "scale=1280:720" -pix_fmt nv12 -f null /dev/null -vf "scale=720:480" -pix_fmt nv12 -f null /dev/null -abr_pipeline
  • Encoding/decoding with VAAPI:
ffmpeg -y -vaapi_device /dev/dri/renderD128 -f rawvideo -video_size 320x240 -r 30 -i test.yuv -vf 'format=nv12, hwupload' -c:v h264_vaapi -y test.mp4
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i test.mp4 -f null /dev/null
  • Encoding/decoding with qsv (Intel Media SDK):
ffmpeg -y -init_hw_device qsv=hw -filter_hw_device hw -f rawvideo -pix_fmt yuv420p -s:v 320x240 -i test.yuv -vf hwupload=extra_hw_frames=64,format=qsv -c:v h264_qsv -b:v 5M test.mp4
ffmpeg -hwaccel qsv -c:v h264_qsv -i test.mp4 -f null /dev/null

Analytics

  • Face detection and emotion identification, save metadata to json format:
ffmpeg -i ~/Videos/xxx.mp4 -vf detect=model=./face-detection-adas-0001/FP32/face-detection-adas-0001.xml:device=CPU, \
classify=model=./emotions_recognition/emotions-recognition-retail-0003.xml:model_proc=emotions-recognition-retail-0003.json:device=CPU \
-an -f iemetadata -source_url $URL -custom_tag $TAG emotion-meta.json
  • Object Detection:
ffmpeg -i ~/Videos/xxx.mp4 -vf detect=model=./mobilenet-ssd.xml:model_proc=mobilenet-ssd.json:device=CPU -an -f null /dev/null
  • Face detection and reidentification:
ffmpeg -i ~/Videos/xxx.mp4 -vf "detect=model=./face-detection-retail-0004.xml:device=CPU, \
classify=model=./face-reidentification-retail-0095.xml:model_proc=./face-reidentification-retail-0095.json:device=CPU" -an -f null /dev/null

ffmpeg -i ~/Videos/xxx.mp4 -vf "detect=model=./face-detection-retail-0004.xml:device=CPU, \
classify=model=./face-reidentification-retail-0095.xml:model_proc=./face-reidentification-retail-0095.json:device=CPU,identify=gallery=./gallery" \
-f iemetadata -y /tmp/face-identify.json
  • Car attribute recognition:
ffmpeg -i ~/Videos/xxx.mp4 -vf "detect=model=vehicle-detection-adas-0002.xml:model_proc=vehicle-detection-adas-0002.json:device=CPU, \
classify=model=vehicle-attributes-recognition-barrier-0039.xml:model_proc=vehicle-attributes-recognition-barrier-0039.json:device=CPU" -an -f null /dev/null
  • Car-Bike-Person detection:
ffmpeg -i ~/Videos/xxx.mp4 -vf "detect=model=person-vehicle-bike-detection-crossroad-0078.xml:model_proc=person-vehicle-bike-detection-crossroad-0078.json:device=CPU" -an -f null /dev/null
  • GPU decode + face detection:
ffmpeg -flags unaligned -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device /dev/dri/renderD128 \
# uncomment to choose different devices:
#-i $STREAM -vf "detect=model=$D_FACE_RT_MODEL:device=CPU" -an -f null - \
#-i $STREAM -vf "detect=model=$D_FACE_RT_FP16_MODEL:device=GPU" -an -f null -
#-i $STREAM -vf "detect=model=$D_FACE_RT_FP16_MODEL:device=VPU" -an -f null -
#-i $STREAM -vf "detect=model=$D_FACE_RT_FP16_MODEL:device=HDDL" -an -f null -