Utilities icon indicating copy to clipboard operation
Utilities copied to clipboard

Screencast: Convert to format suitable for GitHub Issues and Twitter

Open probonopd opened this issue 4 years ago • 1 comments

This format (720p produced by YouTube) is suitable for GitHub Issues and for Twitter. How can we convert our screencasts to it without the need for going via YouTube? I need the exact fffmpeg commands needed to convert existing video into this format.

FreeBSD% ffmpeg -i '/home/user/Desktop/Format suitable for Twitter.mp4'  -f null -
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
  built with FreeBSD clang version 10.0.1 ([email protected]:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)
(...)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/user/Desktop/Format suitable for Twitter.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Google
  Duration: 00:01:38.94, start: 0.000000, bitrate: 314 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 182 kb/s, 29.86 fps, 29.86 tbr, 29861 tbn, 59.72 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf58.76.100
  Stream #0:0(und): Video: wrapped_avframe, yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 29.86 fps, 29.86 tbn (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
      encoder         : Lavc58.134.100 wrapped_avframe
  Stream #0:1(und): Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
      encoder         : Lavc58.134.100 pcm_s16le

probonopd avatar Nov 22 '21 08:11 probonopd

These conversions both work:

ffmpeg -i "/tmp/screencast.mp4" \
  -pix_fmt yuv420p -vcodec libx264 \
  -vf scale=-1:1080 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \
  -acodec aac -vb 1024k \
  -minrate 1024k -maxrate 1024k -bufsize 1024k \
  -ar 44100 -ac 2 -strict experimental -r 30 \
  "/tmp/screencast_small.mp4";
  
ffmpeg -y -i "/tmp/screencast.mp4" -vcodec libx264 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -pix_fmt yuv420p -strict experimental -r 30 -t 2:20 -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -ac 2 "/tmp/screencast_small.mp4"

TODO: Test whether we can record in a compatible format directly, e.g., with

ffmpeg -y -thread_queue_size 1024 -f oss -i "${DSP}" -f x11grab -i :0 -c:v libx264 -preset ultrafast -crf 18 -tune fastdecode -b:v 2000k -minrate 1024k -maxrate 1024k -bufsize 1024k -g 50 -flags +global_header -pix_fmt yuv420p -strict experimental -r 30 -t 2:20 -af highpass-frequency=300 -af lowpass-frequency=4000 -af "bass=frequency=100:gain=-50" -af "bandreject=frequency=200:width_type=h:width=200" -af "compand=attacks=.05:decays=.05:points=-90/-90 -70/-90 -15/-15 0/-10:soft-knee=6:volume=-70:gain=10" -c:a aac -b:a 128k -ac 2 /tmp/screencast.mp4

probonopd avatar Nov 22 '21 12:11 probonopd