Skip to content

Instantly share code, notes, and snippets.

@micolous
Last active January 15, 2020 11:44
Show Gist options
  • Select an option

  • Save micolous/ba93b3833a3957e56377c0c592868a89 to your computer and use it in GitHub Desktop.

Select an option

Save micolous/ba93b3833a3957e56377c0c592868a89 to your computer and use it in GitHub Desktop.

Revisions

  1. micolous revised this gist Jan 15, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions glitch.sh
    Original file line number Diff line number Diff line change
    @@ -18,8 +18,8 @@
    #
    # If you wonder "what is xrandr?" -- it's a command-line tool for Xorg (graphics/display server)
    # that lets you adjust display settings. It's a very powerful tool with a lot of options; but
    # most Linux desktop environments' display settings dialog are good enough to enable a second
    # display in mirroring or extending modes. :)
    # most Linux desktop environments' display settings dialog make it very easy to "just" enable
    # a second display in mirroring or extending modes. :)
    #
    ######
    #
  2. micolous revised this gist Jan 15, 2020. 1 changed file with 27 additions and 4 deletions.
    31 changes: 27 additions & 4 deletions glitch.sh
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,43 @@
    #!/bin/bash
    # "Does anyone know how to use xrandr" glitch slides using FFMPEG. #lca2020
    # "Does anyone know how to use xrandr" glitch slides using ffmpeg. #lca2020
    # Author: Michael Farrell <[email protected]>
    # License: BSD-2-Clause or CC-0 (your choice).
    #
    # Create the "normal" title slide segment from PNG, running for 7 seconds
    ######
    #
    # For linux.conf.au in Gold Coast, Ruan (@xfxf) asked me to make a simple "smoosh / defrag"
    # slide that would be displayed as a holding slide between talks. I made some others with some
    # AV team "in-jokes"... :)
    #
    # On the third day of the conference (2020-01-15), the video generated by this script was shown
    # on-screen: https://twitter.com/glasnt/status/1217220463924928513
    #
    # This uses a title slide, "lca2020-xrandr-720p.png", which is displayed normally for 7 seconds,
    # then "glitches" for 2 seconds, and then returns to normal for 7 seconds. It is intended to be
    # run in a loop.
    #
    # If you wonder "what is xrandr?" -- it's a command-line tool for Xorg (graphics/display server)
    # that lets you adjust display settings. It's a very powerful tool with a lot of options; but
    # most Linux desktop environments' display settings dialog are good enough to enable a second
    # display in mirroring or extending modes. :)
    #
    ######
    #
    # Create the "normal" title slide segment from PNG, running for 7 seconds (xrandr-regular-7s.ts)
    ffmpeg -loop 1 -i lca2020-xrandr-720p.png -t 7 \
    -codec:v mpeg2video -b:v 5000k xrandr-regular-7s.ts

    # Create the "glitched" title slide segment from PNG, running for 2 seconds
    # Create the "glitched" title slide segment from PNG, running for 2 seconds (xrandr-broken-2s.ts)
    # This adds noise every 1000 bytes of the (video) bitstream:
    # Docs: https://ffmpeg.org/ffmpeg-bitstream-filters.html#noise
    ffmpeg -loop 1 -i lca2020-xrandr-720p.png -t 2 \
    -codec:v mpeg2video -bsf:v noise=1000 -b:v 5000k xrandr-broken-2s.ts

    # Stitch the files back together, and re-encode.
    # Stitch the files back together, and re-encode (xrandr-partial.ts)
    # We need to re-encode because the behaviour of glitched bitstream is unpredictable between players.
    ffmpeg -f concat -safe 0 \
    -i <(for f in xrandr-regular-7s.ts xrandr-broken-2s.ts xrandr-regular-7s.ts; do echo "file '$PWD/$f'"; done) \
    -b:v 5000k xrandr-partial.ts

    # That file was called "partial" because my first version of this was _entirely_ glitched.
    # But that was just unreadable. :)
  3. micolous revised this gist Jan 14, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion glitch.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ ffmpeg -loop 1 -i lca2020-xrandr-720p.png -t 7 \
    -codec:v mpeg2video -b:v 5000k xrandr-regular-7s.ts

    # Create the "glitched" title slide segment from PNG, running for 2 seconds
    # This adds noise every 1000 bytes of the bitstream:
    # This adds noise every 1000 bytes of the (video) bitstream:
    # Docs: https://ffmpeg.org/ffmpeg-bitstream-filters.html#noise
    ffmpeg -loop 1 -i lca2020-xrandr-720p.png -t 2 \
    -codec:v mpeg2video -bsf:v noise=1000 -b:v 5000k xrandr-broken-2s.ts
  4. micolous revised this gist Jan 14, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion glitch.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,8 @@ ffmpeg -loop 1 -i lca2020-xrandr-720p.png -t 7 \
    -codec:v mpeg2video -b:v 5000k xrandr-regular-7s.ts

    # Create the "glitched" title slide segment from PNG, running for 2 seconds
    # This adds noise every 1000 bytes of the bitstream.
    # This adds noise every 1000 bytes of the bitstream:
    # Docs: https://ffmpeg.org/ffmpeg-bitstream-filters.html#noise
    ffmpeg -loop 1 -i lca2020-xrandr-720p.png -t 2 \
    -codec:v mpeg2video -bsf:v noise=1000 -b:v 5000k xrandr-broken-2s.ts

  5. micolous revised this gist Jan 14, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions glitch.sh
    Original file line number Diff line number Diff line change
    @@ -4,16 +4,16 @@
    # License: BSD-2-Clause or CC-0 (your choice).
    #
    # Create the "normal" title slide segment from PNG, running for 7 seconds
    ffmpeg -y -loop 1 -i lca2020-xrandr-720p.png -t 7 \
    ffmpeg -loop 1 -i lca2020-xrandr-720p.png -t 7 \
    -codec:v mpeg2video -b:v 5000k xrandr-regular-7s.ts

    # Create the "glitched" title slide segment from PNG, running for 2 seconds
    # This adds noise every 1000 bytes of the bitstream.
    ffmpeg -y -loop 1 -i lca2020-xrandr-720p.png -t 2 \
    ffmpeg -loop 1 -i lca2020-xrandr-720p.png -t 2 \
    -codec:v mpeg2video -bsf:v noise=1000 -b:v 5000k xrandr-broken-2s.ts

    # Stitch the files back together, and re-encode.
    # We need to re-encode because the behaviour of glitched bitstream is unpredictable between players.
    ffmpeg -y -f concat -safe 0 \
    ffmpeg -f concat -safe 0 \
    -i <(for f in xrandr-regular-7s.ts xrandr-broken-2s.ts xrandr-regular-7s.ts; do echo "file '$PWD/$f'"; done) \
    -b:v 5000k xrandr-partial.ts
  6. micolous revised this gist Jan 14, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions glitch.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,8 @@
    #!/bin/bash
    # "Does anyone know how to use xrandr" glitch slides using FFMPEG. #lca2020
    # Author: Michael Farrell <[email protected]>
    # License: BSD-2-Clause or CC-0 (your choice).
    #
    # Create the "normal" title slide segment from PNG, running for 7 seconds
    ffmpeg -y -loop 1 -i lca2020-xrandr-720p.png -t 7 \
    -codec:v mpeg2video -b:v 5000k xrandr-regular-7s.ts
  7. micolous created this gist Jan 14, 2020.
    15 changes: 15 additions & 0 deletions glitch.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/bin/bash
    # Create the "normal" title slide segment from PNG, running for 7 seconds
    ffmpeg -y -loop 1 -i lca2020-xrandr-720p.png -t 7 \
    -codec:v mpeg2video -b:v 5000k xrandr-regular-7s.ts

    # Create the "glitched" title slide segment from PNG, running for 2 seconds
    # This adds noise every 1000 bytes of the bitstream.
    ffmpeg -y -loop 1 -i lca2020-xrandr-720p.png -t 2 \
    -codec:v mpeg2video -bsf:v noise=1000 -b:v 5000k xrandr-broken-2s.ts

    # Stitch the files back together, and re-encode.
    # We need to re-encode because the behaviour of glitched bitstream is unpredictable between players.
    ffmpeg -y -f concat -safe 0 \
    -i <(for f in xrandr-regular-7s.ts xrandr-broken-2s.ts xrandr-regular-7s.ts; do echo "file '$PWD/$f'"; done) \
    -b:v 5000k xrandr-partial.ts