Skip to content

Instantly share code, notes, and snippets.

@alifeee
Last active December 11, 2024 13:02

Revisions

  1. alifeee revised this gist Dec 11, 2024. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions ffmpeg-commands.md
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,14 @@ ffmpeg -i input.mp4 -b:v 0 -crf 30 -pass 1 -an -f webm -y /dev/null
    ffmpeg -i input.mp4 -b:v 0 -crf 30 -pass 2 output.webm
    ```

    ## turn a video into one Mastodon will like

    from <https://www.dannyvankooten.com/blog/2023/resize-downsample-video-ffmpeg/>

    ```bash
    ffmpeg -i in.webm -filter:v scale=1900:-1,fps=60 out.webm
    ```

    ## Export frame from mp4

    Select frame `34`
  2. alifeee revised this gist Oct 28, 2024. 1 changed file with 24 additions and 0 deletions.
    24 changes: 24 additions & 0 deletions ffmpeg-commands.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,23 @@
    # FFmpeg Commands

    ## see video information

    ```bash
    # see all information
    ffmpeg -i input.mp4
    # format resolution nicely
    ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4
    ```

    ## resize video

    ```bash
    # limit height to 720px
    ffmpeg -i input.mp4 -vf scale="trunc(oh*a/2)*2:720" out.mp4
    # limit width to 720px
    ffmpeg -i input.mp4 -vf scale="720:trunc(ow/a/2)*2" out.mp4
    ```

    ## Turn mp4 into gif

    Used [here](https://github.com/sheffieldhackspace/train-signs). From [here](https://superuser.com/a/1695537).
    @@ -24,3 +42,9 @@ Select frame `34`
    ```bash
    ffmpeg -i <input> -vf "select=eq(n\,34)" -vframes 1 out.png
    ```

    ## mute a video

    ```bash
    ffmpeg -i $input_file -c copy -an $output_file
    ```
  3. alifeee revised this gist Jul 30, 2024. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion ffmpeg-commands.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,15 @@ ffmpeg -y -i input.mp4 -filter_complex "fps=5,scale=480:-1:flags=lanczos,split[s

    For `webm` videos, two passes should be made. on Windows, redirect to `NUL` instead of `/dev/null`

    ```
    ```bash
    ffmpeg -i input.mp4 -b:v 0 -crf 30 -pass 1 -an -f webm -y /dev/null
    ffmpeg -i input.mp4 -b:v 0 -crf 30 -pass 2 output.webm
    ```

    ## Export frame from mp4

    Select frame `34`

    ```bash
    ffmpeg -i <input> -vf "select=eq(n\,34)" -vframes 1 out.png
    ```
  4. alifeee revised this gist Jul 30, 2024. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions ffmpeg-commands.md
    Original file line number Diff line number Diff line change
    @@ -7,3 +7,12 @@ Used [here](https://github.com/sheffieldhackspace/train-signs). From [here](http
    ```bash
    ffmpeg -y -i input.mp4 -filter_complex "fps=5,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=32[p];[s1][p]paletteuse=dither=bayer" output.gif
    ```

    ## Turn mp4 into webm

    For `webm` videos, two passes should be made. on Windows, redirect to `NUL` instead of `/dev/null`

    ```
    ffmpeg -i input.mp4 -b:v 0 -crf 30 -pass 1 -an -f webm -y /dev/null
    ffmpeg -i input.mp4 -b:v 0 -crf 30 -pass 2 output.webm
    ```
  5. alifeee created this gist Mar 14, 2024.
    9 changes: 9 additions & 0 deletions ffmpeg-commands.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # FFmpeg Commands

    ## Turn mp4 into gif

    Used [here](https://github.com/sheffieldhackspace/train-signs). From [here](https://superuser.com/a/1695537).

    ```bash
    ffmpeg -y -i input.mp4 -filter_complex "fps=5,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=32[p];[s1][p]paletteuse=dither=bayer" output.gif
    ```