Skip to content

Instantly share code, notes, and snippets.

@JeansBolong
Last active March 15, 2021 10:44
Show Gist options
  • Save JeansBolong/caf5d3cfff42602faf12310df7ad4536 to your computer and use it in GitHub Desktop.
Save JeansBolong/caf5d3cfff42602faf12310df7ad4536 to your computer and use it in GitHub Desktop.
FFMPEG

Compress untuk 1 video

ffmpeg -i path/inputVideo.mp4 -vcodec h264 -acodec aac outputVideo.mp4

Convert mp4 to HLS format video

ffmpeg -i input.mp4 -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls index.m3u8

Untuk loop video dalam folder yg ada file name

for i in *.mp4;
  do name=`echo new_$i | cut -d'.' -f1`;
  echo $name;
  ffmpeg -i "$i" -vcodec h264 -acodec aac "${name}_new.mp4";
done

resize video resolution

ffmpeg -i input.avi -vf scale=320:240 output.avi

Record on mac webcam using ffmpeg

ffmpeg -f avfoundation -framerate 30 -i 0:0 -pix_fmt yuv420p output.mov

Generate image from video every 1s (fps)

ffmpeg -i input.mp4 -vf fps=1 out%d.png

Generate image from video every frame

ffmpeg -i video.webm thumb%04d.jpg -hide_banner

Streaming to youtube

ffmpeg -i [input video] -codec copy -f flv rtmp://a.rtmp.youtube.com/live2/[key streaming]

Capture screen stream to yotube

ffmpeg -framerate 30 -video_size 1920x1080 -f x11grab -i :1 -f pulse -i default -c:v libx264 -b:v 5000k -maxrate 5000k -bufsize 10000k -g 60 -vf format=yuv420p -c:a aac -b:a 128k -f flv rtmp://a.rtmp.youtube.com/live2/stream_key

Capture screen macOS

  • Get all available input devices including screens ready to be captured.
ffmpeg -f avfoundation -list_devices true -i ""
  • Once you've figured out the device index corresponding to the screen to be captured, use:
ffmpeg -framerate 30 -video_size 1280x720 -f avfoundation -i "<screen device index>:<audio device index>" output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment