Skip to content

Instantly share code, notes, and snippets.

@gildotdev
Last active October 30, 2017 00:31
Show Gist options
  • Save gildotdev/1447239 to your computer and use it in GitHub Desktop.
Save gildotdev/1447239 to your computer and use it in GitHub Desktop.

Revisions

  1. gildotdev revised this gist Nov 2, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ffmpeg.txt
    Original file line number Diff line number Diff line change
    @@ -33,3 +33,5 @@ ffmpeg -i original.mp4 -f srt -i subtitle.srt -c:v copy -c:a copy -c:s mov_text
    ## convert first audio track to 2 channel aac and copy first audio track to second audio track
    ffmpeg -i original.mkv -map 0:0 -map 0:1 -map 0:1 -c:v copy -c:a:0 libfaac -b:a:0 192k -ac 2 -c:a:1 copy new.mp4

    ## create animated gif
    ffmpeg -i original.mp4 -s wxh -pix_fmt rgb24 -r 24 -f gif - | gifsicle --optimize=3 --delay=3 > new.gif
  2. gildotdev revised this gist Jan 29, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion ffmpeg.txt
    Original file line number Diff line number Diff line change
    @@ -28,4 +28,8 @@ ffmpeg -i foo.flv -vcodec copy -acodec copy bar.mp4
    ffmpeg -i foo.flv -vcodec copy -acodec aac -aq 200 bar.mp4

    ## add subtitles to mp4 from srt
    ffmpeg -i original.mp4 -f srt -i subtitle.srt -c:v copy -c:a copy -c:s mov_text new.mp4
    ffmpeg -i original.mp4 -f srt -i subtitle.srt -c:v copy -c:a copy -c:s mov_text new.mp4

    ## convert first audio track to 2 channel aac and copy first audio track to second audio track
    ffmpeg -i original.mkv -map 0:0 -map 0:1 -map 0:1 -c:v copy -c:a:0 libfaac -b:a:0 192k -ac 2 -c:a:1 copy new.mp4

  3. Gil Creque revised this gist Dec 11, 2013. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions ffmpeg.txt
    Original file line number Diff line number Diff line change
    @@ -19,12 +19,13 @@ ffmpeg -i foo.mp4 -ab 64k -ar 44100 -f flv bar.flv
    ## convert folder full of .m4a to .mp3
    for f in *.m4a; do ffmpeg -i "$f" -acodec mp3 -ab 256k "${f%.m4a}.mp3"; done

    ##convert .flv to .mp4
    ##assuming a/v codecs in the flv are what you want (i.e. h264 and aac)
    ## convert .flv to .mp4
    ## assuming a/v codecs in the flv are what you want (i.e. h264 and aac)
    ffmpeg -i foo.flv -vcodec copy -acodec copy bar.mp4

    ##convert .flv to .mp4 (with aac audio)
    ##assuming video codec in the flv is what you want (i.e. h264)
    ## convert .flv to .mp4 (with aac audio)
    ## assuming video codec in the flv is what you want (i.e. h264)
    ffmpeg -i foo.flv -vcodec copy -acodec aac -aq 200 bar.mp4


    ## add subtitles to mp4 from srt
    ffmpeg -i original.mp4 -f srt -i subtitle.srt -c:v copy -c:a copy -c:s mov_text new.mp4
  4. gildotdev revised this gist Mar 5, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions ffmpeg.txt
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,9 @@ ffmpeg -i foo.mp3 -acodec aac -ab 128k -strict experimental bar.aac
    ## extract single frame as image from .mp4
    ffmpeg -i foo.mp4 -ss 0 -vframes 1 -vcodec mjpeg -f image2 bar.jpg

    ## convert movie to image sequence
    ffmpeg -i foo.mp4 bar%d.png

    ## convert .mp4 to .flv
    ffmpeg -i foo.mp4 -ab 64k -ar 44100 -f flv bar.flv

  5. gildotdev revised this gist Sep 10, 2012. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions ffmpeg.txt
    Original file line number Diff line number Diff line change
    @@ -18,8 +18,10 @@ for f in *.m4a; do ffmpeg -i "$f" -acodec mp3 -ab 256k "${f%.m4a}.mp3"; done

    ##convert .flv to .mp4
    ##assuming a/v codecs in the flv are what you want (i.e. h264 and aac)
    fmpeg -i foo.flv -vcodec copy -acodec copy bar.mp4
    ffmpeg -i foo.flv -vcodec copy -acodec copy bar.mp4

    ##convert .flv to .mp4 (with aac audio)
    ##assuming video codec in the flv is what you want (i.e. h264)
    ffmpeg -i foo.flv -vcodec copy -acodec aac -aq 200 bar.mp4
    ffmpeg -i foo.flv -vcodec copy -acodec aac -aq 200 bar.mp4


  6. gildotdev revised this gist Sep 6, 2012. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion ffmpeg.txt
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,12 @@ ffmpeg -i foo.mp4 -ss 0 -vframes 1 -vcodec mjpeg -f image2 bar.jpg
    ffmpeg -i foo.mp4 -ab 64k -ar 44100 -f flv bar.flv

    ## convert folder full of .m4a to .mp3
    for f in *.m4a; do ffmpeg -i "$f" -acodec mp3 -ab 256k "${f%.m4a}.mp3"; done
    for f in *.m4a; do ffmpeg -i "$f" -acodec mp3 -ab 256k "${f%.m4a}.mp3"; done

    ##convert .flv to .mp4
    ##assuming a/v codecs in the flv are what you want (i.e. h264 and aac)
    fmpeg -i foo.flv -vcodec copy -acodec copy bar.mp4

    ##convert .flv to .mp4 (with aac audio)
    ##assuming video codec in the flv is what you want (i.e. h264)
    ffmpeg -i foo.flv -vcodec copy -acodec aac -aq 200 bar.mp4
  7. gildotdev revised this gist Jul 24, 2012. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion ffmpeg.txt
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,7 @@ ffmpeg -i foo.mp3 -acodec aac -ab 128k -strict experimental bar.aac
    ffmpeg -i foo.mp4 -ss 0 -vframes 1 -vcodec mjpeg -f image2 bar.jpg

    ## convert .mp4 to .flv
    ffmpeg -i foo.mp4 -ab 64k -ar 44100 -f flv bar.flv
    ffmpeg -i foo.mp4 -ab 64k -ar 44100 -f flv bar.flv

    ## convert folder full of .m4a to .mp3
    for f in *.m4a; do ffmpeg -i "$f" -acodec mp3 -ab 256k "${f%.m4a}.mp3"; done
  8. gildotdev created this gist Dec 8, 2011.
    14 changes: 14 additions & 0 deletions ffmpeg.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    ## extract audio from .avi as .aac (conversion from another audio codec)
    ffmpeg -i foo.avi -acodec aac -ab 128k -strict experimental bar.aac

    ## extract audio from .avi as .mp3 (no conversion, just copy)
    ffmpeg -i foo.avi -acodec copy bar.mp3

    ## convert .mp3 to .aac
    ffmpeg -i foo.mp3 -acodec aac -ab 128k -strict experimental bar.aac

    ## extract single frame as image from .mp4
    ffmpeg -i foo.mp4 -ss 0 -vframes 1 -vcodec mjpeg -f image2 bar.jpg

    ## convert .mp4 to .flv
    ffmpeg -i foo.mp4 -ab 64k -ar 44100 -f flv bar.flv