This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Multimedia

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

Linux multimedia encompasses a wide range of tools and applications designed for handling audio, video, and image files. These tools enable users to create, edit, and play multimedia content, making Linux a versatile platform for multimedia production and consumption. From professional-grade video editing software to simple audio players, Linux offers a variety of options to suit different needs.

Audio tools on Linux include applications for recording, editing, and mixing sound. These tools support various audio formats and provide features like multi-track editing, effects processing, and real-time monitoring. They are widely used by musicians, podcasters, and sound engineers for producing high-quality audio content.

Video tools on Linux offer capabilities for video editing, transcoding, and playback. These applications support a wide range of video formats and provide features like timeline editing, special effects, and color correction. They are used by filmmakers, video editors, and content creators to produce professional-grade videos.

Image tools on Linux include software for photo editing, graphic design, and image manipulation. These tools provide features like layer-based editing, filters, and vector graphics support. They are used by photographers, designers, and artists to create and enhance visual content.

Overall, Linux multimedia tools provide a robust and flexible environment for creating and managing multimedia content. They cater to both amateur and professional users, offering a wide range of features and customization options. With a strong community of developers and users, Linux continues to be a powerful platform for multimedia production and innovation.

1 - 🖥️avconv

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the avconv command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#   █████╗ ██╗   ██╗ ██████╗ ██████╗ ███╗   ██╗██╗   ██╗
#  ██╔══██╗██║   ██║██╔════╝██╔═══██╗████╗  ██║██║   ██║
#  ███████║██║   ██║██║     ██║   ██║██╔██╗ ██║██║   ██║
#  ██╔══██║╚██╗ ██╔╝██║     ██║   ██║██║╚██╗██║╚██╗ ██╔╝
#  ██║  ██║ ╚████╔╝ ╚██████╗╚██████╔╝██║ ╚████║ ╚████╔╝ 
#  ╚═╝  ╚═╝  ╚═══╝   ╚═════╝ ╚═════╝ ╚═╝  ╚═══╝  ╚═══╝  

# Split video files using avconv along keyframes
avconv -i SOURCE.mp4 -f segment -c:v copy -bsf:v h264_mp4toannexb -an -reset_timestamps 1 OUTPUT_%05d.h264
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

2 - 🖥️faad

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the faad command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗ █████╗  █████╗ ██████╗ 
#  ██╔════╝██╔══██╗██╔══██╗██╔══██╗
#  █████╗  ███████║███████║██║  ██║
#  ██╔══╝  ██╔══██║██╔══██║██║  ██║
#  ██║     ██║  ██║██║  ██║██████╔╝
#  ╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚═════╝ 

faad                            - freeware Advanced Audio Decoder player

# Convert m4a files to mp3 using faad and lame
faad -o tmp.wav music.m4a && lame -b 192 tmp.wav music.mp3
# Explanation: 
    # Step 1: convert m4a to wav using faad
    # Step 2: convert wav to mp3 using lame
    # -b 192 is the bitrate
# Limitations: Neither faad nor lame are standard commands.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

3 - 🖥️ffmpeg

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ffmpeg command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗███████╗███╗   ███╗██████╗ ███████╗ ██████╗ 
#                ██╔════╝██╔════╝████╗ ████║██╔══██╗██╔════╝██╔════╝ 
#                █████╗  █████╗  ██╔████╔██║██████╔╝█████╗  ██║  ███╗
#                ██╔══╝  ██╔══╝  ██║╚██╔╝██║██╔═══╝ ██╔══╝  ██║   ██║
#                ██║     ██║     ██║ ╚═╝ ██║██║     ███████╗╚██████╔╝
#                ╚═╝     ╚═╝     ╚═╝     ╚═╝╚═╝     ╚══════╝ ╚═════╝ 
                                                                    

# Print file metadata etc.
ffmpeg -i path/to/file.ext

# Convert all m4a files to mp3
for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -vn -b:a 320k "${f%.m4a}.mp3"; done

# Convert video from .foo to .bar
#    -g : GOP, for searchability
ffmpeg -i input.foo -vcodec bar -acodec baz -b:v 21000k -b:a 320k -g 150 -threads 4 output.bar

# Convert image sequence to video
ffmpeg -r 18 -pattern_type glob -i '*.png' -b:v 21000k -s hd1080 -vcodec vp9 -an -pix_fmt yuv420p -deinterlace output.ext

# Combine video and audio into one file
ffmpeg -i video.ext -i audio.ext -c:v copy -c:a copy output.ext

# Listen to 10 seconds of audio from a video file
#    -ss       : start time
#    -t        : seconds to cut
#    -autoexit : closes ffplay as soon as the audio finishes
ffmpeg -ss 00:34:24.85 -t 10 -i path/to/file.mp4 -f mp3 pipe:play | ffplay -i pipe:play -autoexit

ffmpeg -i input.mp4 -f null /dev/null
# Get video information with ffmpeg
# Fix for PHP Shell Exec: ffmpeg -i input.mp4 -f null /dev/null 2>&1 shell_exec("ffmpeg -i input.mp4 -f null /dev/null 2>&1");

# windows
for %%a in ("*.flv") do ffmpeg -i "%%a" -vcodec copy -c:a aac -b:a 128k -bsf aac_adtstoasc "newfiles\%%~na.mp4"
     pause
# I need lossless video conversion but the audio converted to something more compatible then that codec cb uses. I need something that can batch convert as I have lots and lots of files.

ffmpeg -i film.AVI -c:a aac -b:a 128k -c:v libx264 -crf 23 film.mp4
#    .avi to .mp4
#         -acodec libfaac
#    This uses the faac codec to encode the audio to aac.
#         -b:a 128k and -b:v 1200k
#    These are the audio and video (respectively) bitrates of 128kb and 1200kb
#         -flags +aic+mv4

ffmpeg -i file.avi -vcodec libx264 -vpre lossless_slow -crf 25 -acodec libfaac -threads 0 -t 60 file.mp4
# ffmpeg command to convert AVI files to MP4

ffmpeg -i video.flv -crf 26 video.mp4
# .flv to mp4
#    -crf = Quantizer Scale from 0-51 (lossless->worst) 23 is default

ffmpeg -i video.flv image%d.jpg
# split a video into images - image1.jpg image2.jpg usw.

ffmpeg -f image2 -i image%d.jpg imagestovideo.mpg
# convert images into a video - convert image1.jpg image2.jpg usw to a video imagesovideo.mpg

ffmpeg -i test_%d.jpg -vcodec mpeg4 test.avi
#

ffmpeg -framerate 25 -i image-%05d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4
# create a video file from a set of jpg images 
#    -framerate          - is the number of frames (images) per second
#    -i scene_%05d.jpg   - his determines the file name sequence it looks for. 0 is the number repeated, and the 5 is number of times starting at image-00000.jpg
#    -c:v libx264        -profile:v high -crf 20 -pix_fmt yuv420p
#    -c:v libx264        - the video codec is libx264 (H.264).
#    -profile:v high     - use H.264 High Profile (advanced features, better quality).
#    -crf 20             - constant quality mode, very high quality (lower numbers are higher quality, 18 is the smallest you would want to use).
#    -pix_fmt yuv420p    - use YUV pixel format and 4:2:0 

ffmpeg -i video.flv -vn -ar 44100 -ac 2 -ab 192 -f mp3 audio.mp3
# To convert an .flv format video file to Mp3 format, run the following command
#    -vn: helps to disable video recording during the conversion.
#    -ar: helps you set audio sampling rate in Hz.
#    -ab: set the audio bitrate.
#    -ac: to set the number of audio channels.
#    -f:  format.

ffmpeg -i video.flv video.mpg
# To convert a .flv video file to .mpg, use the following command.

ffmpeg -i video.flv animated.gif.mp4
# To convert a .flv video file to animated, uncompressed gif file, use the command below.

ffmpeg -i video.mpg -ab 26k -f flv video1.flv
# To convert a .mpg file to .flv format, use the following command.

ffmpeg -i video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 video.mpeg
# To convert a .avi file to mpeg for dvd players, run the command
#    -target pal-dvd     : Output format
#    -ps 2000000000      : max. size for the output file, in bits (here, 2 Gb).
#    -aspect 16:9        : Widescreen.

ffmpeg -i video.mpg -target vcd vcd_video.mpg
# Convert a video to CD or DVD format - To create a video CD or DVD, FFmpeg makes it simple by letting you specify a target type and the format options required automatically. You can set a target type as follows: add -target type; type can of the following be vcd, svcd, dvd, dv, pal-vcd or ntsc-svcd on the command line.

ffmpeg -i video1.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 audio3.mp3
# To extract sound from a video file, and save it as Mp3 file
#      Source video        : video.avi
#      Audio bitrate       : 192kb/s
#      output format       : mp3
#      Generated sound     : audio3.mp3

ffmpeg -i audio.mp3 -i video.avi video_audio_mix.mpg
# Mix a video and audio together

ffmpeg -i video.mpg -vf "setpts=0.5*PTS" highspeed.mpg
# Increase/Reduce Video Playback Speed -vf option sets the video filters that helps to adjust the speed.

ffmpeg -i video.mpg -vf "setpts=4.0*PTS" lowerspeed.mpg -hide_banner
# reduce video speed as follows -hide_banner option it will hide all FFmpeg tools copyright information

ffplay video1.mp4
# This helps you to test videos and audio quality.

ffmpeg -loop 1 -i image.jpg -i Bryan\ Adams\ -\ Heaven.mp3 -c:v libx264 -c:a aac -strict experimental -b:a 192k -shortest output.mp4
# Add Photo or Cover/Banner to Audio File

ffmpeg -i video.mp4 -i subtitles.srt -map 0 -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast video-output.mkv
# Add subtitles to a Movie - a separate subtitle file called subtitle.srt

ffmpeg -f concat -safe 0 -i <(for f in ./*.wav; do echo "file '$PWD/$f'"; done) -c copy output.wav
ffmpeg -f concat -safe 0 -i <(printf "file '$PWD/%s'\n" ./*.wav) -c copy output.wav
ffmpeg -f concat -safe 0 -i <(find . -name '*.wav' -printf "file '$PWD/%p'\n") -c copy output.wav
# Mehrere Dateien zu einer zusammenfügen.  Make sure to generate absolute paths here, since ffmpeg will resolve paths relative to the list file your shell may create in a directory such as "/proc/self/fd/".

for i in {1..10}; do printf "file '%s'\n" input.mkv >> mylist.txt; done
ffmpeg -f concat -i mylist.txt -c copy output.mkv
# Mehrere Dateien concat/zusammenfuegen. You can also loop a video. This example will loop input.mkv 10 times

ffmpeg -i in.mp4 -vf select='not(mod(n,15))',setpts=N/FRAME_RATE/TB out.mp4
	# Another method is to use the framestep filter
ffmpeg -i in.mp4 -vf framestep=15,setpts=N/FRAME_RATE/TB out.mp4
# To take every 15th frame

ffmpeg -start_number 1 -i _DSF%04d.JPG -c:v libx264 -pix_fmt yuv420p video.mp4
# Finally, make the darned movie-> like -start_number and the _DSF%04d.JPG format) to make things match up. This tells FFmpeg to take all of the JPEGs in the directory starting with _DSF and ending with 4 digits, and to output an h.264 video with the yuv420p colorspace to video.mp4. You now have a beautiful timelapse!

ffmpeg -r 24 -pattern_type glob -i '*.JPG' -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4
# Convert sequence of JPEG images to MP4 video
#	-r 24 - output frame rate
#	-pattern_type glob -i '*.JPG' - all JPG files in the current directory
#	-i DSC_%04d.JPG - e.g. DSC_0397.JPG
#	-s hd1080 - 1920x1080 resolution Slower, better quality

# Add the following after -vcodec libx264 to achieve better quality output
#	-crf 18 -preset slow

convert input.jpg -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' output.jpg
# Bulk convert JPGs to 1920x1080, centered

ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4
# Problem solved. I wasn not  removing the audio, so presumably it was playing the, near empty, audio file for the full time of the video.
# 	-an removes the audio from the video.

ffmpeg -f image2 -pattern_type glob -i 'cap-*.jpg' -r 25 -vcodec h264 -vb 4096k -acodec null -s 1920x1280 -pix_fmt yuvj422p video.mp4
# Create the FHD video

ffmpeg -f image2 -pattern_type glob -i 'cap-*.jpg' -r 25 -vcodec h264 -acodec null -pix_fmt yuvj422p -s 6000x4000 video-6k.mp4
# for the 6k version (same as my camera resolution)

for FILE in `ls *.JPG`; do \
  mogrify -resize 1280x720^ -gravity center -crop 1280x720+0+0 +repage -write RESIZED_PHOTO_DIRECTORY/$FILE $FILE; \
done

for FILE in `ls *.JPG`; do \
    mogrify -resize 600x -write RESIZED_PHOTO_DIRECTORY/$FILE $FILE; \
done
# Resizing 4896x3264). pretty huge in this case, 1280x720 n detail, this command -resizes photos to a 1280x720^ resolution (the caret means that the smaller of width and height is maintained and the larger one is kept even if the resolution is larger), and then, by using -gravity and centering, we crop the image to 1280x720 exactly, and write to RESIZED_PHOTO_DIRECTORY/$FILE. Phew, that was a mouthful.
# If you just want to resize to a certain height/width and want to maintain the original resolution

ffmpeg -f aac -analyzeduration 100M -probesize 100M -i broken.m4a -c copy fixed.m4a
# Need to fix a broken M4A file with a corrupted header? 

ffmpeg -re -i "index.m3u8" -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 426x240 -bufsize 6000k -vb 400k -maxrate 1500k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -f flv "rtmp://rtmp-api.facebook.com"
# gute frage

ffmpeg m3u8 facebook live
# ffmpeg covert m3u8 to facebook live stream

ffmpeg -re -y -i mm.mp4 -b:a 128k -vcodec libx264 -pix_fmt yuv420p -vf scale=640:480 -r 30 -g 60 -f flv "rtmp://rtmp-api.facebook.com:80/rtmp/xxxxxxxxxx"
# ffmpeg facebook

ffmpeg mp4 to facebook live steam
# ffmpeg facebook

# Videohokuspokus mit ffmpeg
#============================#

##ffmpeg

# ou can use this command to make the list
ls *.avi | while read each; do echo "file '$each'" >> mylist.txt; done

# Then pass that file to ffmpeg
ffmpeg -f concat -i mylist.txt -c copy video_draft.avi

ffmpeg \
  -i input1.mp4 \
  -i input2.mp4 \
  -filter_complex '[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid]' \
  -map [vid] \
  -c:v libx264 \
  -crf 23 \
  -preset veryfast \
  output.mp4
 
 
 ffmpeg -i left.mp4 -i right.mp4 -filter_complex \
"[0:v][1:v]hstack=inputs=2[v]; \
 [0:a][1:a]amerge[a]" \
-map "[v]" -map "[a]" -ac 2 output.mp4
#    hstack will place each video side-by-side.
#    amerge will combine the audio from both inputs into a single, multichannel audio stream, and -ac 2 will make it stereo; without this option the audio stream may end up as 4 channels if both inputs are stereo.

### FFMPEG - Merge two MP4 files
#-------------------------------------#

# You would list your input files in a text file (mylist.txt) and then:
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
# The -safe 0 is not required if the paths are relative.

# Covert wmv to avi with FFmpeg:
apt-get install ffmpeg
ffmpeg -i input.wmv output.avi

# Convert wmv to avi with MEncoder:
apt-get install mencoder
mencoder input.wmv -o output.avi -ofps 23.976 -ovc lavc -oac copy

# How to identify video formats from command line on Linux
#------------------------------------------------------------#
## Method One
exiftool input.mp4 

## Method Two
apt-get install tovid
tovid id input.mp4 

##  Method Three
mplayer -vo null -ao null -identify -frames 0 input.mp4

## Method Four
ffmpeg -i input.mp4 

# ffmpeg ist ein Kommandozeilen-Tool zur Konvertierung aller gängigen Codecs - quasi ein schweizer Taschenmesser der Video- und Audio-Bearbeitung. Zuhause ist das Projekt auf ffmpeg.mplayerhq.hu. Auf meiner Suche nach irgendeinem Linux-Tool zum Umwandeln von Video-Dateien, musste ich feststellen, dass ffmpeg zwar alles kann, aber leider schlecht dokumentiert ist. Das hat mich veranlasst, hier ein paar praxisnahe Beispiele zusammenzustellen (ziemlich unsortiert).

# Wichtig: Es gibt Unterschiede zwischen der Windows- und der Linux-Version von ffmpeg. Darum möchte ich klarstellen, dass es hier ausschließlich um Linux geht.

### Zuerst: Versionen-Check
#-----------------------------#
# ffmpeg ist nicht gleich ffmpeg - aus lizenzrechtlichen Gründen. Bevor Ihr meine Beispiele ausprobiert, vergleicht erst mal die Versionen:
# ffmpeg -version
 
FFmpeg version SVN-r10937, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --shlibdir=/usr/lib --prefix=/usr --mandir=/usr/share/man 
  --libdir=/usr/lib --enable-shared --enable-libmp3lame --enable-libogg 
  --enable-libvorbis --enable-libtheora --enable-libfaad --enable-libfaac 
  --enable-libxvid --enable-liba52 --enable-swscaler 
  --enable-pp --enable-gpl --enable-vhook --enable-x11grab --enable-libgsm 
  --enable-libx264 --enable-libamr-nb --enable-libamr-wb
  libavutil version: 49.5.0
  libavcodec version: 51.47.2
  libavformat version: 51.17.1
  built on Nov  7 2007 00:26:14, gcc: 4.1.2 20061115 (prerelease) (SUSE Linux)
FFmpeg SVN-r10937
libavutil   3212544
libavcodec  3354370
libavformat 3346689

Ohne libmp3lame habt Ihr keine Unterstützung für mp3.
Ohne liba52 könnt Ihr keine DVDs de/encodieren.

Meines ist ein fixfertiges SuSE-rpm von Packman, in dem alles Nötige schon dabei ist. Anleitungen zum Kompilieren findet Ihr anderswo. Folgt den Links.

Beispiel 1: Animation aus Einzelbildern
Ich habe (aus Gimp oder SynfigStudio) eine Serie durchnummerierter Bilder exportiert und möchte daraus eine Animation machen.
Das Ganze funktioniert natürlich nicht nur mit JPG, sondern auch mit PNG, aber die Transparenz geht verloren.

ffmpeg -f image2 -i img%d.jpg output.mpg

werden mehr als 9 Bilder benötigt:

ffmpeg -f image2 -i img%02d.jpg output.mpg
	-f image2 teilt ffmpeg das Eingabeformat mit (Bilder)
	-i img%d.jpg die Input-Datei(en)
	%d ist ein Platzhalter für eine einstellige Zahl
	%02d für eine zweistellige Zahl, %03d für eine dreistellige, usw.
	output.mpg die Ausgabe-Datei (hier mpg, könnte aber auch z.B. avi oder flv sein)

Anhand der Dateiendung der Ausgabe-Datei kann ffmpeg allerlei Default-Einstellungen setzen, die Ihr aber jederzeit auch überschreiben könnt.
Ein Beispiel dafür wäre eine höhere Video-Bitrate, das bedeutet eine bessere Qualität des Filmes, aber auch eine größere Datei:

ffmpeg -f image2 -i img%02d.jpg -b 500k output2.mpg
	-b 500k setzt die Video-Bitrate auf 500kbit/s (der default-Wert ist 200k)

Ob die Animation gelungen ist, könnt Ihr gleich überprüfen:

ffplay output.mpg

Ein kleiner Videoplayer ist nämlich im ffmpeg Paket mit dabei.

###Beispiel 2: Tonspur hinzufügen
#-----------------------------#
Ich möchte diese Animation um eine Tonspur ergänzen. Sind Video- und Sound-File gleich lang, ist das denkbar einfach:

ffmpeg -i video.avi -i sound.mp3 -sameq videomitsound.avi
	-sameq Video-Qualität des Input-Files beibehalten

Nun will ich einer Animation (einem Video) ohne Ton eine leise Hintergrundmusik verpassen. Das mp3 mit der Hintergrundmusik ist länger als das Video und zu laut.

ffmpeg -shortest -i video.avi -vcodec copy -i sound.mp3 -vol 20 -acodec libmp3lame -ac 2 -ab 128k output1.avi
	-shortest hör auf, wenn das kürzeste Inputfile endet.
	-vcodec copy die Videospur einfach nur kopieren
	-vol 20 Lautstärke (20 ist ziemlich leise)
	-acodec libmp3lame Audiocodec mp3 (default wäre mp2)
	-ac 2 zwei Kanäle (Stereo), default wäre Mono
	-ab 128k Audiobitrate von 128kbit/s (default 64k)

Ob sich -sameq und -vcodec copy in diesem Fall (der Codec ändert sich ja nicht) gleich verhalten, weiß ich nicht.
Wird die Audiospur komplizierter, z.B. ein leises Hintergrundgeräusch, darüber gelegentlich Musik abwechselnd mit einem/r Sprecher/in, ist ffmpeg überfordert. Dann ist Audacity das Programm der Wahl zur Audiobearbeitung.

###Beispiel 3: Transcodieren
#-----------------------------#
Mit meiner kleinen Digitalkamera habe ich ein Filmchen aufgenommen, das jetzt verkleinert und in ein Flash-Movie konvertiert werden soll.
Zuerst möchte ich mal wissen, womit ich es hier zu tun habe:

ffmpeg -i CIMG0269.AVI

ffmpeg gibt schon mal jede Menge Informationen über den Film aus (Auszug):

Input #0, avi, from 'CIMG0269.AVI':
Duration: 00:02:57.3, start: 0.000000, bitrate: 3964 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 29.97 fps(r)
Stream #0.1: Audio: adpcm_ima_wav, 44100 Hz, mono, 177 kb/s

Container: avi
Länge: 2min 57,3 sek
Bitrate: 3964 kb/s
Codec: mpeg4
Pixelformat: yuv420p
Größe: 640x480 px
Seitenverhältnis: 4:3
Framerate: 29.97 fps (Frames pro Sekunde)
Und darunter noch eine vergleichbare Zeile zum Audiokanal (wav).

Folgendes ist eigentlich ein Einzeiler, ich habe die Zeile aber in Video und Audio getrennt, um es übersichtlicher zu machen.

ffmpeg -i CIMG0269.AVI -s 400x300 -b 512k -async 50 -acodec libmp3lame -ar 11025 -ab 16k output_klein.flv
	-s 400x300 die Größe in Pixel
	-b 512k die Video-Bitrate
	-async 50 die Audiospur wird auf die Länge des Filmes gestaucht/gestreckt, das ist nötig, weil sich der Audio-Codec ändert.
	-acodec libmp3lame der Audiocodec wird mp3 (statt wav)
	-ar 11025 die Audio Sampling Frequenz wird verringert (von 44100 Hz)
	-ab 16k die Audio-Bitrate wird tüchtig heruntergeschraubt (von 177 kb/s)

###Beispiel 4: Thumbnails extrahieren
#-----------------------------------------#
Ich möchte aus einem Film Thumbnails (kleine Bilder) extrahieren.

ffmpeg -an -ss 0:0:2 -t 0:0:0.001 -i input.mp4 -f image2 -s 110x90 thumb%d.jpg
	-an Ton brauche ich dazu überhaupt nicht
	-ss 0:0:2 Start bei 2 Sek. (der Vorspann ist bei diesem Film uninteressant)
	-t 0:0:0.001 die Dauer (1/1000 Sekunde)
	-s 110x90 die Größe des Thumbnails - wie immer bei ffmpeg ist die Reihenfolge der Argumente wichtig!
	thumb%d.jpg %d, weil es auch mehr als ein Bild sein könnte

###Beispiel 5: Diashow
#-----------------------------#
Ich möchte aus mehreren jpegs eine Diashow erstellen. Die Bilder sind in der gewünschten Reihenfolge durchnummeriert, allerdings zu groß (die Auflösung der Kamera).

ffmpeg -r 0.3 -f image2 -i img%d.jpg -r 25 -b 512k -s vga output.avi

Die Reihenfolge der Argumente ist wichtig.
	-r 0.3 die Framerate des Inputs, ein Bild wird dann ca. 3 Sek. lang angezeigt
	-f image2 das Eingabeformat (Bilder)
	-r 25 die Framerate des Outputs, 25 Frames pro Sekunde
	-s vga die Größe in Pixel, vga ist eine Abkürzung für 640x480 (siehe ffmpegs manpage)

Etwas seltsam ist, dass es mit dem ersten Bild ein Problem gibt, es wird zu kurz gezeigt. Ich schätze, das liegt an der Input-Framerate. Mein Trick: das erste Bild verdoppeln (cp img1.jpg img0.jpg), den obigen Befehl wiederholen und dann vom Anfang des Filmes ein Stück wegschneiden (wieder mit ffmpeg).

ffmpeg -i output.avi -ss 0:0:0.6 -sameq output_clean.avi

###Beispiel 6: Audiocodecs
#-----------------------------#
Ich möchte ein wav (=unkomprimiertes) Audiofile in mp3 oder oggvorbis konvertieren.
Grundsätzlich genügt für mp3:

ffmpeg -i sound.wav sound.mp3

Allerdings ist die default Audiobitrate bei ffmpeg 64kbit/s. Das ist sehr schlechte Audioqualität. Deshalb setze ich die Bitrate auf 192kbit/s (sehr gut).

ffmpeg -i sound.wav -ab 192k sound2.mp3

Für oggvorbis funktioniert das ganz ähnlich.

ffmpeg -i sound.wav sound.ogg

Einen Unterschied zu mp3 gibt es beim Setzen der besseren Audioqualität.

ffmpeg -i sound.wav -aq 10 sound2.ogg
	-aq 10 setzt die Audioqualität (oggvorbis hat eine variable Bitrate).

Was es mit -aq auf sich hat, wird auf www.vorbis.com erklärt (englisch).
Vergleichen wir doch mal die Dateigrößen (Das Musikstück ist 2min 50s lang).

   29M  sound.wav
  4,1M  sound2.ogg
  4,0M  sound2.mp3
  1,4M  sound.mp3
  1,2M  sound.ogg

Wie man ID3 Tags mit ffmpeg setzen kann, habe ich tatsächlich auch noch heraus gefunden.
	-title der Titel des Musikstücks
	-author der Autor
	-album das Album

Natürlich ist ffmpeg unpraktisch, wenn man eine ganze CD rippen will, aber zwischendurch schnell mal was konvertieren geht prima. Vor allem wenn man Videocodec und Audiocodec in einem Rutsch bearbeitet.

###Beispiel 7: Filme aneinander hängen
#------------------------------------------#
Ich möchte mehrere kurze Filme (Animationen) aneinanderhängen zu einem längeren Film:
Wichtig dabei ist, dass alle die gleichen Bitraten, Auflösungen, Codecs und Frameraten haben müssen!
Leider funktioniert das nur mit mpeg1 und mpeg2 und ist außerdem verlustbehaftet, weil transcodiert werden muss.

cat film1.mpeg film2.mpeg > film_t.mpeg

ffmpeg -i film_t.mpeg -sameq langfilm.mpeg

Ja, das gute alte cat. Ihr habt richtig gesehen.
Der zweite Schritt setzt die Timestamps wieder richtig.
	-sameq Video-Qualität des Input-Files möglichst beibehalten

Zwei überaus gefinkelte Methoden, wie Filme aneinandergehängt werden können, werden hier beschrieben:
	1) mit mkfifo und/oder yuv4mpegpipe: ffmpeg.org/faq.html
	2) mit redirects und image2pipe: www.wlug.org.nz/FFmpeg

###Beispiel 8: Tonspur extra bearbeiten
#------------------------------------------#
Ich möchte die Tonspur eines Filmes getrennt nachbearbeiten (mit Audacity), die Videospur aber unverändert lassen. Zuerst extrahiere ich den Sound.

ffmpeg -i film.mp4 -vn audio.wav

Als Ausgabeformat wähle ich das unkomprimierte wav. Der original Audiocodec des Filmes wäre mpeg4aac, Audacity kann aber mit .aac nicht umgehen, da das ein proprietäres Format ist. (Update: konnte!, Audacity nimmt inzwischen ffmpeg zu Hilfe.)
ffmpeg kommt damit klar, wenn libfaac einkompiliert ist (--enable-libfaac).
	-vn die Videospur wird nicht benötigt

Außerdem brauche ich die Videospur ohne Audio in einem Extrafile.

ffmpeg -i film.mp4 -an -vcodec copy film_stumm.mp4
	-an ohne Ton
	-vcodec copy die Videospur unverändert kopieren

Nachdem ich das audio.wav mit Audacity bearbeitet und als mp3 exportiert habe (audio.mp3), setze ich die stumme Videospur und das neue Soundfile zusammen.

ffmpeg -i film_stumm.mp4 -i audio.mp3 -vcodec copy -async 10 -ab 128k newfilm.mp4

ffmpeg konvertiert die Audiospur automatisch wieder in mpeg4aac.
	-vcodec copy das Video einfach nur kopieren
	-async 10 durch die (mehrmalige) Änderung des Codecs ist das Soundfile ein paar Sekunden länger als der Film. ffmpeg staucht das wieder zurecht, damit Bild und Ton synchron bleiben.
	-ab 128k die Audio-Bitrate (Qualität)

###Beispiel 9: anamorphe Filme korrigieren
#-------------------------------------------#
Hasst Ihr das nicht auch, wenn 16:9 Filme auf 4:3 gezerrt werden (ohne Balken) und alle Gesichter befremdend nach Bananen oder Gurken aussehen? Man bezeichnet das als anamorph. Mir persönlich sind die schwarzen Balken oben und unten lieber.
Hier habe ich z.B. so einen Problemfall: Das Video hat eine Auflösung von 352x288px. Das ist nicht wirklich 4:3, aber fast. Damit das Ganze halbwegs ein Seitenverhältnis von 16:9 kriegt, ändere ich die Auflösung auf 352x200. Dann sehen die Gesichter auch wieder menschlich aus.

ffmpeg -i banane.flv -s 352x200 -acodec copy -sameq normal.flv
	-s 352x200 das neue Seitenverhältnis
	-acodec copy die Tonspur unverändert kopieren
	-sameq die Videoqualität beibehalten

Schlussendlich sollte der ganze Film aber doch wieder ein Seitenverhältnis von 4:3 bekommen, nur eben mit Balken.

Kopfrechnen:
4:3=1,333333333
352:1,333333333=264,000...
(264-200):2=32
Die Balken oben und unten müssen jeweils 32 Pixel hoch sein.

ffmpeg -i banane.flv -s 352x200 -padtop 32 -padbottom 32 -acodec copy -sameq normal2.flv 
	-padtop 32 oben einen Balken von 32 Pixel Höhe dazu
	-padbottom 32 unten auch

###Beispiel 10: Film archivieren
#--------------------------------#
Eine DVD rippen als Backup, oder um z.B. einen Home Media Server zu betreiben.

Was ist nötig:
Ein DVD Laufwerk :)
vobcopy und ffmpeg
ffmpeg mit folgenden Libraries:

    libmp3lame
    liba52

Plattenplatz zu hauf
Eine wahnsinns CPU oder Geduld.

Zuerst folgende Programme installieren:
libdvdread und vobcopy
Vobcopy brauchen wir, um die .VOB Dateien aus der DVD zu extrahieren. Vobcopy benötigt dazu wiederum libdvdread.
Die DVD einlegen, Informationen einholen, dann mit vobcopy auf Festplatte kopieren.

vobcopy -I

vobcopy -m -o /home/ein/ordner/

Mehr zu vobcopy mit man vobcopy
Variante: Falls Ihr Mplayer installiert habt, könnt Ihr das Ganze auch direkt mit dem Player machen.

mplayer dvd://2 -dumpstream -dumpfile /home/mein/ordner/title2.vob

Das kopiert den zweiten Titel der DVD auf Festplatte.

In den Arbeitsordner wechseln und gleich nochmal neugierig sein.

ffmpeg -i VTS_01_1.VOB

Input #0, mpeg, from 'VTS_01_1.VOB':
Duration: 00:24:47.5, start: 0.360000, bitrate: 5224 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 
			[PAR 64:45 DAR 16:9], 6430 kb/s, 25.00 fps(r)
Stream #0.1[0x80]: Audio: liba52, 48000 Hz, stereo, 192 kb/s
Stream #0.2[0x81]: Audio: liba52, 48000 Hz, stereo, 192 kb/s
Stream #0.3[0x21]: Subtitle: dvdsub

Zum Testen brauche ich nur die ersten 20 Sekunden des Filmes, dann kann ich mich an mein Wunschergebnis annähern, ohne ganze Tage davor zu sitzen.

ffmpeg -i VTS_01_1.VOB -t 0:0:20 test.avi

Dieses test.avi schaue ich mir mit ffplay, mplayer und totem an.
Tatsächlich ist der Film scheußlich verzerrt (16:9 auf 4:3) und die Qualität ist zu schlecht. Nach vielen Versuchen, finde ich die richtigen Einstellungen.

ffmpeg -i VTS_01_1.VOB -b 900k -s 640x480 -aspect 4:3 -acodec libmp3lame -ab 128k -async 50 ausgabe.avi -padtop 60 -padbottom 60
	-b 900k Videobitrate von 900kbit/s, ein Kompromiss zwischen Qualität und Dateigröße
	-s 640x480 die Auflösung in Pixel
	-aspect 4:3 das Seitenverhältnis muss ich diesmal angeben, um das originale zu überschreiben
	-acodec libmp3lame Audiocodec mp3
	-ab 128k Audiobitrate (default wäre 64kbit/s)
	-async 50 stellt sicher, dass Bild und Ton synchron bleiben (der Audiocodec ändert sich ja)
	-padtop 60 oben ein Balken von 60 Pixel Höhe
	-padbottom 60 unten auch

Eine Anmerkung zur Zeit: Zum Umwandeln des 24 min 47 s langen Filmes benötigte ffmpeg mit meiner 1.30GHz CPU ca. 17 min. Das ist doch gar nicht so schlecht.

Zur Dateigröße:

VTS_01_1.VOB  927MB
ausgabe.avi   185MB

Prima! 

Ich muss vorausschicken, dass ich absolut keine Video-Expertin bin. Dieses ganze Howto beruht auf "learning by doing". Die Dokumentation zu ffmpeg ist dürftig (ich erwähnte es schon), sogar die manpage ist hoffnungslos veraltet. Die Dokumentation von Mplayer/mencoder, die auf ffmpeg basieren, ist deutlich besser. Da viele Optionen recht ähnlich heißen, hilft mitunter die mencoder Dokumentation weiter.

Warum ich dann nicht gleich mencoder verwende, fragt ihr?

    ich finde ffmpeg flexibler
    mencoder hat (noch) ein paar ganz fiese kleine Bugs (naja, ffmpeg auch)
    eine Laune, ich mag die langen mencoder Code-Würste nicht

###Beispiel 11:
#-----------------------------#

Nun will ich die Konvertierung der DVD (vgl. Beispiel 10) noch optimieren: Es ist immer ein Kompromiss zwischen Rechenzeit zur Kodierung, Dateigröße und Qualität.

Die erste Frage ist: "Welcher Container/Codec ist der beste?" - Die Antwort darauf kann schnell religiöse Züge annehmen, ich persönlich halte die Frage für nicht beantwortbar.

x264 wird hoch gelobt (mit Recht), aber mein schwaches Rechnerlein hat keine Freude damit - das Transkodieren ist sehr CPU-lastig und dauert ewig.
AVI - geht schnell, aber die Qualität bei gleicher Dateigröße ist eher mau.
Theora - ist in ffmpeg momentan sehr buggy, also nicht zu gebrauchen. ffmpeg2theora (es basiert auf ffmpeg) ist wiederum zu langsam beim Codieren (eventuell liegts auch am Codec selbst).

Schlussendlich fällt meine Wahl auf mp4: Das Transkodieren geht relativ schnell, die Datei ist klein genug bei brauchbarer Qualität.

###Die Vorgehensweise:
#-----------------------------#
    Seitenverhältnis und Größe (in Pixeln) ausknobeln
    Bitraten testen (Video und Audio)
    Qualität optimieren mit 2-Pass-Encoding

Die VOB-Datei, kopiert mit Mplayer (siehe Beispiel 10) auf meine Festplatte, hat folgendes Innenleben:

ffmpeg -i title2.vob

Input #0, mpeg, from 'title2.vob':
Duration: 00:23:11.5, start: 0.360000, bitrate: 5057 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p,
              720x576 [PAR 64:45 DAR 16:9], 6430 kb/s, 25.00 fps(r)
Stream #0.1[0x80]: Audio: liba52, 48000 Hz, stereo, 192 kb/s
Stream #0.2[0x81]: Audio: liba52, 48000 Hz, stereo, 192 kb/s
Stream #0.3[0x21]: Subtitle: dvdsub

Der Film ist etwas über 23 Min. lang, hat eine sehr unpraktische Auflösung, zwei mal die gleiche Tonspur und Untertitel, die ich nicht brauche.
Ich fange mit den Grundeinstellungen an und arbeite mich zur gewünschen Qualität vor.

ffmpeg -i title2.vob -t 30 test1.mp4
	-t 30 nur (die ersten) 30 Sek. des Filmes

###Experimentieren:
#-----------------------------#

Zur Auflösung: Ich möchte eine Letterbox (16:9 Film mit Balken oben und unten), die endgültige Höhe und Breite sollte aber durch 16 teilbar sein (Makroblocks). Das klappt mit dieser Auflösung nicht, deshalb muss ich skalieren (das Bild etwas verkleinern).

ffmpeg bietet eine Vielzahl an (schlecht dokumentierten) Filtern zur Verbesserung der Qualität an. Ich experimentiere auch tüchtig, aber das bisschen Verbesserung rechtfertigt meist die zusätzliche Rechenzeit nicht.
Nur -mbd rd bringt bei diesem Film und diesem Codec wirklich etwas (MacroBlock Decision).
Ein Tipp: ffmpeg zeigt eine Statuszeile, die so ausschaut:

frame=  758 fps= 42 q=5.1 Lsize=    3968kB time=30.0 bitrate=1083.0kbits/s

fps sind die Frames, die pro Sekunde berechnet werden. Damit kann man recht genau hochrechnen, wie lange die Umwandlung des Ganzen Filmes dauern wird. Mit Lsize kann man die Dateigröße hochrechnen.

Hoppla, die Audioqualität darf ich nicht vergessen. Eine Audio-Bitrate von 128kb sollte genügen. Da sich der Audiocodec ändert, verwende ich auch noch -async 50, damit Bild und Ton synchron bleiben.
Stunden später... :)

ffmpeg -i title2.vob -t 30 -s 704x528 -aspect 4:3 -b 1200k -mbd rd -ab 128k -async 50 test1.mp4 -padtop 66 -padbottom 66
	-t 30 noch immer sind es nur 30 Sek.
	-s 704x528 Breite und Höhe in Pixel, beides teilbar durch 16
	-aspect 4:3 das Seitenverhältnis
	-b 1200k Video-Bitrate in kbit/s
	-mbd rd macroblock decision=rate distortion
	-ab 128k Audio-Bitrate
	-async 50 siehe oben
test1.mp4 die Ausgabe-Datei
	-padtop 66 der obere Balken, 66 Pixel hoch
	-padbottom 66 der untere Balken

###Jetzt kommt der Clou: 2-Pass-Encoding
#------------------------------------------------#
Das bedeutet, dass das selbe File zwei mal hintereinander Encodiert wird, wobei ffmpeg das erste mal ein Logfile schreibt, das es beim zweiten Durchgang zur Optimierung verwendet. Siehe Wikipedia. Es dauert dann zwar doppelt so lange, aber das ist es auch wert.

ffmpeg -i title2.vob -pass 1 -t 30 -s 704x528 -aspect 4:3 -b 1200k -mbd rd -ab 128k -async 50 test11.mp4 -padtop 66 -padbottom 66

ffmpeg -i title2.vob -y -pass 2 -t 30 -s 704x528 -aspect 4:3 -b 1200k -mbd rd -ab 128k -async 50 test11.mp4 -padtop 66 -padbottom 66
	-pass 1 der erste Durchgang
	-y ja, das erste File überschreiben
	-pass 2 der zweite Durchgang
	-t 30 30 Sek., wie gehabt

Diesen 30-Sekunden-Schnipsel begutachte ich kritisch. Nein, ich sehe absolut keinen Qualitäts-Unterschied mehr zur DVD. Auch die letzten Blockartefakte sind verschwunden. Und das bei weniger als einem Drittel der Dateigröße der VOB-Datei (DVD).
Dann kanns losgehen, jetzt kriegt mein Rechenknecht ordentlich zu tun:

ffmpeg -i title2.vob -pass 1 -s 704x528 -aspect 4:3 -b 1200k -mbd rd \
	-ab 128k -async 50 test11.mp4 -padtop 66 -padbottom 66

ffmpeg -i title2.vob -y -pass 2 -s 704x528 -aspect 4:3 -b 1200k -mbd rd \
	-ab 128k -async 50 test11.mp4 -padtop 66 -padbottom 66

# encode video with constant framerate
ffmpeg -i input.mp4 -vcodec libx264 -crf 30 output.mp4

# convert ogg files to mp3 preserving the id3v2 tags - Converts an OGG file to MP3 at desired quality, preserving the id3v2 tags.
ffmpeg -i input.ogg -ab 256k -map_metadata 0:s:0 output.mp3

ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -pix_fmt uyvy422 -i "0" -c:v h264_videotoolbox -profile:v high -b:v 3M -color_range 1 /tmp/out.mp4
# Capture video Macbook webcam with cpu accelerated Captures video from webcam and encodes it using the accelerated hardware provided by videotoolbox framework. It takes about 20% cpu in a i5 2015 macbook air.

#-----------------------------------------------------------------------///

# Dateien mit Leerzeichen im Namen verarbeiten
#-----------------------------------------------------------------------///
# Konkretes Beispiel: es soll auf die Schnelle ein Stapel wav Dateien mit ffmpeg in mp3 konvertiert werden, die Dateinamen haben aber leider ein Leerzeichen (Track 1.wav usw.). Die Lösung: die Umgebungsvariable IFS (Internal Field Separator) umschreiben. Hinweis: der Ordner "mp3" muss natürlich vorher von Hand angelegt werden.

# Folgendes scheitert am Leerzeichen:
for f in *.wav; do ffmpeg -i "$f" "../mp3/${f}.mp3"; done;

# Wenn ich vorher aber die IFS Variable auf Zeilenumbruch setze, klappt es:
IFS='                                                                  
'
for f in *.wav; do ffmpeg -i "$f" "../mp3/${f}.mp3"; done;

# Danach sollte IFS wieder auf den ursprünglichen Wert, also Leerzeichen, gesetzt werden:
IFS=' '

# Extract audio
ffmpeg -i Aaliyah\ +\ Tim\ \&\ Bob\ -\ Rock\ the\ Boat\ \(Duncan\ Gerow\ Mix\)-CnDUZCtALWI.mp4 -c:a copy -vn -sn Aaliyah\ +\ Tim\ \&\ Bob\ -\ Rock\ the\ Boat\ \(Duncan\ Gerow\ Mix\)-CnDUZCtALWI.m4a

# Concat wavs, make mp3/flac
shntool join 2016-11-28_20h17m44.wav 2016-11-28_20h17m44_01h02m53.wav
lame -q0 -b256 joined.wav
flac --repla    y-gain -8 joined.wav

# Webm to mp3
FILE="the-file-you-want-to-process.webm";
ffmpeg -i "${FILE}" -vn -ab 128k -ar 44100 -y "${FILE%.webm}.mp3";

## ffmpeg .flv to .m4a
# first check the input
ffmpeg -i inputfile.flv
ffmpeg -i input.flv -vn -acodec copy output.m4a

# Still... I was trying to control the framerate for a final animation with convert (without success). So, change the gifs to pngs and do:
ffmpeg -y -i %03d.png -r 30 radar.gif; rm ???.png 
# this will create radar.gif animation
# -r 30 will control the frame rate.

# Capture video of a linux desktop This will grab the image from desktop, starting with the upper-left corner at x=100, y=200 with a width and height of 1024?768.
ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output.mp4

# Convert any 16:9 video to play on a QHD widescreen Android phone
ffmpeg -i $1 -y -threads 0 -subq 6 -deinterlace -level 30 -f mp4 -acodec libfaac -ab 160k -ar 24000 -ac 2 -vcodec libx264 -b 1000k -maxrate 1000k -bufsize 2000k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 2 -flags +loop -vol 256 -trellis 1 -me_method umh -async 1 $2
# Explanation: The Android video player is somewhat fussy about the formats it can play. This ffmpeg script will take any movie file in 16:9 widescreen format and convert it into a form that can be played on one of the current leading QHD phones such as HTC Sensation, Samsung Galaxy S2 or Motorola Atrix. Files that are merely marked as widescreen (e.g. DVD VOBs) will have to be processed into a true widescreen format such as .m2t first.
# Parameters:
	# $1 the input file
	# $2 the output file
	# Output file suffix should be .mp4
# Requires: ffmpeg and codecs

# Convert from avi format to mp4 encoding
ffmpeg -i file.avi file.mp4
# Explanation: FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.
# Limitations: It is not a standard package in most systems and distros.

# Rotate a video file by 90 degrees CW - Change video orientation in metadata only
ffmpeg -i in.mov -c copy -metadata:s:v:0 rotate=90 out.mov

    
# Count the total number of hours of your music collection
find . -print0 | xargs -0 -P 40 -n 1 sh -c 'ffmpeg -i "$1" 2>&1 | grep "Duration:" | cut -d " " -f 4 | sed "s/.$//" | tr "." ":"' - | awk -F ':' '{ sum1+=$1; sum2+=$2; sum3+=$3; sum4+=$4; if (sum4 > 100) { sum3+=1; sum4=0 }; if (sum3 > 60) { sum2+=1; sum3=0 }; if (sum2 > 60) { sum1+=1; sum2=0 } if (NR % 100 == 0) { printf "%.0f:%.0f:%.0f.%.0f\n", sum1, sum2, sum3, sum4 } } END { printf "%.0f:%.0f:%.0f.%.0f\n", sum1, sum2, sum3, sum4 }'

# Extract audio only from video files using ffmpeg
ffmpeg -i video.any -vn -acodec libvorbis audio.ogg

# Downmix first audio stream from 7.1 to 5.1 keeping all other streams - Useful for Roku which does not support 7.1. Useful resources: - https://trac.ffmpeg.org/wiki/Map - https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio - https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg
ffmpeg -i in.mkv -map 0 -c copy -c:a:0 aac -ac:a:0 6 out.mkv

# Rotate a video file by 90 degrees CW - Transpose parameter: 0 = 90CounterCLockwise and Vertical Flip (default) 1 = 90Clockwise 2 = 90CounterClockwise 3 = 90Clockwise and Vertical Flip
ffmpeg -i in.mov -vf "transpose=1" out.mov

#==============================##==============================#
# CMD ffmpeg						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

4 - 🖥️lame

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lame command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██╗      █████╗ ███╗   ███╗███████╗
#  ██║     ██╔══██╗████╗ ████║██╔════╝
#  ██║     ███████║██╔████╔██║█████╗  
#  ██║     ██╔══██║██║╚██╔╝██║██╔══╝  
#  ███████╗██║  ██║██║ ╚═╝ ██║███████╗
#  ╚══════╝╚═╝  ╚═╝╚═╝     ╚═╝╚══════╝

# Minimal example of converting a wave file to MP3
lame input.wav output.mp3

# Re-encode existing MP3 to 64 kbps MP3
lame -b 64 original.mp3 new.mp3

# Encode with variable bitrate (quality=2) 
# 0 <= quality <= 9  (default = 4).  0 = highest quality
lame -V2 original.wav compressed.mp3

# More interesting options
# -m m: save as mono
# -m s: save as stereo
# -m j: save as joint stereo (exploits inter-channel correlation
#       more than regular stereo)
# -q 2: quality tweaking: the lower the value, the better the 
#       quality, but the slower the algorithm. Default is 5.
#
# By default, lame uses constant bit rate (CBR) encoding. 
# You can also use average bit rate (ABR) encoding, 
# e.g. for an average bit rate of 123 kbps:
lame --abr 123 input.wav output.mp3

# Variable (VBR) encoding, e.g. between 32 kbps and 192 kbps:
lame -v -b 32 -B 192 input.wav output.mp3

# Recode all wav files in all subdirectories
find . -type d -exec sh -c '(cd {} && for i in *.wav; do lame -h -b 128 "$i" "`basename "$i" .wav`".mp3; done)' ';' 
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

5 - 🖥️mencoder

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the mencoder command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ███╗███████╗███╗   ██╗ ██████╗ ██████╗ ██████╗ ███████╗██████╗ 
#                ████╗ ████║██╔════╝████╗  ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔══██╗
#                ██╔████╔██║█████╗  ██╔██╗ ██║██║     ██║   ██║██║  ██║█████╗  ██████╔╝
#                ██║╚██╔╝██║██╔══╝  ██║╚██╗██║██║     ██║   ██║██║  ██║██╔══╝  ██╔══██╗
#                ██║ ╚═╝ ██║███████╗██║ ╚████║╚██████╗╚██████╔╝██████╔╝███████╗██║  ██║
#                ╚═╝     ╚═╝╚══════╝╚═╝  ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝  ╚═╝
                                                                                      
                                                                                    

# To convert a series of jpg files to an avi movie that can be displayed by, for example, Quicktime Player with no add-ons, use:
mencoder "mf://*.jpg" -o movie.avi -ovc lavc -lavcopts vcodec=mjpeg

# Notes:
#    It can also make mpeg movies but these do not seem readable by Quicktime Player
#    Other vcodecs may give more efficient or higher quality results and be playable on some players, but mjpeg is the only one I found to work with the standard Quicktime Player
#    To download mencoder for MacOSX, particularly for Intel CPU, follow the link at http://ffmpegx.com/download.html .

# Useful discussions are on Wikipedia and here.

# Other Possibilities
# ffmpeg or ppmtompeg (discussed here) or mjpeg.

      
#-----------------------------------------------------------------#
       
        
         
# Join several videos with Mencoder
#=====================================#

# Here is how to merge several video files into a signle one with Mencoder.
# It is pretty easy, here it is:

mencoder -oac copy -ovc copy -idx -o output.avi video1.avi video2.avi video3.avi
#    The -oac copy option tells mencoder to just copy the audio  stream (no reencoding). -ovc copy does the same with the video stream.
#    The -idx option asks mencoder to build the index if none was found. This makes searchin  g inside the video easier.
#         -o stands for "output" and specifies the o  utput file.

# The last few parameters are the input video files.
# You can join as many files as you like. This will work for videos of the same resolution, and using the same codec, but any video format that mencoder recognizes is fine.

# Easy with mencoder (shipped with mplayer in Arch Linux):
mencoder -oac copy -ovc copy video1.avi video2.avi -o final.avi

# Or avimerge
avimerge -o cd.avi -i cd1.avi cd2.avi

# Concatenate two or more movie files into one using mencoder
mencoder cd1.avi cd2.avi -o movie.avi -ovc copy -oac copy

# Explanation: 
    # You can specify as many files as you want on the command line to process them in sequence.
    # -ovc copy simply means to copy the video exactly
    # -oac copy simply means to copy the audio exactly
    # -o movie.avi is the output file, with all the source files concatenated

# Limitations: 
    # mencoder is usually not a standard package
    # mencoder may be in the same package as mplayer, or maybe not
    # mencoder has binary packages for Linux, Mac and Windows

See the MPlayer homepage for more info: http://www.mplayerhq.hu/

# Rotate a movie file with mencoder
mencoder video.avi -o rotated-right.avi -oac copy -ovc lavc -vf rotate=1

# Explanation: mencoder is part of mplayer.

# Other possible values of the rotate parameter:
    # 0: Rotate by 90 degrees clockwise and flip (default).
    # 1: Rotate by 90 degrees clockwise.
    # 2: Rotate by 90 degrees counterclockwise.
    # 3: Rotate by 90 degrees counterclockwise and flip.

#==============================##==============================#
# CMD MENCODER						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

6 - 🖥️mplayer

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the mplayer command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ███╗██████╗ ██╗      █████╗ ██╗   ██╗███████╗██████╗ 
#                ████╗ ████║██╔══██╗██║     ██╔══██╗╚██╗ ██╔╝██╔════╝██╔══██╗
#                ██╔████╔██║██████╔╝██║     ███████║ ╚████╔╝ █████╗  ██████╔╝
#                ██║╚██╔╝██║██╔═══╝ ██║     ██╔══██║  ╚██╔╝  ██╔══╝  ██╔══██╗
#                ██║ ╚═╝ ██║██║     ███████╗██║  ██║   ██║   ███████╗██║  ██║
#                ╚═╝     ╚═╝╚═╝     ╚══════╝╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝  ╚═╝
                                                                            
                                                                            
                                                                          
mplayer recent.mp4 -loop 0 -speed 8 
# Play a video file recent.mp4 at 8x speed, looping it seamlessly forever.

mplayer -vo dummy -ao dummy -identify * 2>&1 | grep ID_LENGTH  | sed 's/.*=\([0-9]*\)/\1/' | xargs echo | sed 's/ /+/g' | bc | awk 'S=$1; {printf "%dh:%dm:%ds\n",S/(60*60),S%(60*60)/60,S%60}'
# Get the total length of all videos in the current dir in H:m:s
# You're behind on your TV catch-up, but how far behind? This command tries to open mplayer against all files in the current dir. If it's a video file it will contain ID_LENGTH, which is summed and output in hours, minutes and seconds.
# Someone better at awk could probably reduce this down a lot.

mplayer -endpos 0.1 -vo null -ao null -identify *.avi 2>&1 |grep ID_LENGTH |cut -d = -f 2|awk '{SUM += $1} END { printf "%d:%d:%d\n",SUM/3600,SUM%3600/60,SUM%60}'
# Get the total length of all video / audio in the current dir in H:m:s

soxi -D * | awk '{SUM += $1} END { printf "%d:%d:%d\n",SUM/3600,SUM%3600/60,SUM%60}'
# Get the total length of all video / audio in the current dir (and below) in H:m:s - Uses soxi instead of mplayer

mplayer 0[89]??18*.mp4 
# Play videos form Aug/Sep 2018. My phone camera app has a weird date format (MMYYDD_HHMMSS). Fortunately I can find videos I've synced to backup easily enough with globbing expressions. ? means match anything in that one place. [89] means match 8 or 9.

mplayer M?rklintage* 
# If you encounter a file that is hard to type/tab complete, try using a ? to replace the characters you can't type.

mplayer -vo png -ss 3:46 -frames 20 stairs.mp4 
# Write out 20 png format frames from a video starting at 3 minutes, 46 seconds.

mplayer -fs $( youtube-dl -g 'http://www.youtube.com/watch?v=tjUgxpl9ttg …' ) 
# Watch youtube video directly in mplayer, fullscreen.

#==============================##==============================#
# CMD MPLAYER						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

7 - 🖥️mpv

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the mpv command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███╗   ███╗██████╗ ██╗   ██╗
#  ████╗ ████║██╔══██╗██║   ██║
#  ██╔████╔██║██████╔╝██║   ██║
#  ██║╚██╔╝██║██╔═══╝ ╚██╗ ██╔╝
#  ██║ ╚═╝ ██║██║      ╚████╔╝ 
#  ╚═╝     ╚═╝╚═╝       ╚═══╝

# Listen to the radio (radio2 in example)
mpv http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_two.m3u8
# Explanation: MPV is a terminal audio player. You could also use vlc or any media player that supports streams. To find a stream for your favourite uk radio station, look here: UK Audio Streams. If you are outside of the uk, Google is your friend
# Limitations: Requires an audio player that supports streams.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

8 - 🖥️rtmpdump

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the rtmpdump command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#      ██████╗ ████████╗███╗   ███╗██████╗ ██████╗ ██╗   ██╗███╗   ███╗██████╗ 
#      ██╔══██╗╚══██╔══╝████╗ ████║██╔══██╗██╔══██╗██║   ██║████╗ ████║██╔══██╗
#      ██████╔╝   ██║   ██╔████╔██║██████╔╝██║  ██║██║   ██║██╔████╔██║██████╔╝
#      ██╔══██╗   ██║   ██║╚██╔╝██║██╔═══╝ ██║  ██║██║   ██║██║╚██╔╝██║██╔═══╝ 
#      ██║  ██║   ██║   ██║ ╚═╝ ██║██║     ██████╔╝╚██████╔╝██║ ╚═╝ ██║██║     
#      ╚═╝  ╚═╝   ╚═╝   ╚═╝     ╚═╝╚═╝     ╚═════╝  ╚═════╝ ╚═╝     ╚═╝╚═╝     
                                                                                        
                

rtmpdump -v -r "aljazeeraflashlive-live.fplive.net" | vlc -
    -v live
    -r rtmp protocoll
    vlc - piping to vlc

	 
#==============================##==============================#
# CMD RTMPDUMP						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

9 - 🖥️sox

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the sox command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗ ██████╗ ██╗  ██╗
#  ██╔════╝██╔═══██╗╚██╗██╔╝
#  ███████╗██║   ██║ ╚███╔╝ 
#  ╚════██║██║   ██║ ██╔██╗ 
#  ███████║╚██████╔╝██╔╝ ██╗
#  ╚══════╝ ╚═════╝ ╚═╝  ╚═╝

# sox
# Sound eXchange: play, record and convert audio files.
# Audio formats are identified by the extension.

# Merge two audio files into one:
sox -m ${input_audiofile1} ${input_audiofile2} ${output_audiofile}

# Trim an audio file to the specified times:
sox ${input_audiofile} ${output_audiofile} trim ${start} ${end}

# Normalize an audio file (adjust volume to the maximum peak level, without clipping):
sox --norm ${input_audiofile} ${output_audiofile}

# Reverse and save an audio file:
sox ${input_audiofile} ${output_audiofile} reverse

# Print statistical data of an audio file:
sox ${input_audiofile} -n stat

# Increase the volume of an audio file by 2x:
sox -v 2.0 ${input_audiofile} ${output_audiofile}

# Changing sample rate of a file
sox ${input_file} -r 16000 ${output_file}

# Changing the Number of Channels
# For example: convert mono audio files to stereo
sox ${mono_wav} -c 2 ${stereo_wav}

# Generate Different Types of Sounds
# ${len} - length of audio to synthesize, hh:mm:ss.frac
# ${freq} - frequencies at the beginning/end of synthesis in Hz
# ${type} is one of sine, square, triangle, sawtooth, trapezium, exp, 
#   [white]noise, pinknoise, brown-noise
# sox -n synth ${len} ${type} ${freq}
sox -r 8000 -n output.wav synth 3 sine 300-3300

# Speed up the Sound in an Audio File
sox input.wav output.wav speed 2.0

# Record audio from microphone or sound input from the console
sox -t ossdsp -w -s -r 44100 -c 2 /dev/dsp -t raw - | lame -x -m s - File.mp3
    # Explanation: sox is a software that lets you connect directly to the sound card and send what passes for it in raw format and the system memory through the concatenation of the linux command we can make real-time audio processing is generated by licks and be converted to mp3.
    # Limitations: Requires a plugin for alsa oss to run on modern distributions.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

10 - 🖥️soxi

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the soxi command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗ ██████╗ ██╗  ██╗██╗
#  ██╔════╝██╔═══██╗╚██╗██╔╝██║
#  ███████╗██║   ██║ ╚███╔╝ ██║
#  ╚════██║██║   ██║ ██╔██╗ ██║
#  ███████║╚██████╔╝██╔╝ ██╗██║
#  ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═╝

# Get basic information about an audio file
# (like the number of channels, sample rate, duration, etc)
soxi file.mp3
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

11 - 🖥️youtube-dl

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the youtube-dl command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#    ██╗   ██╗ ██████╗ ██╗   ██╗████████╗██╗   ██╗██████╗ ███████╗██████╗ ██╗     
#    ╚██╗ ██╔╝██╔═══██╗██║   ██║╚══██╔══╝██║   ██║██╔══██╗██╔════╝██╔══██╗██║     
#     ╚████╔╝ ██║   ██║██║   ██║   ██║   ██║   ██║██████╔╝█████╗  ██║  ██║██║     
#      ╚██╔╝  ██║   ██║██║   ██║   ██║   ██║   ██║██╔══██╗██╔══╝  ██║  ██║██║     
#       ██║   ╚██████╔╝╚██████╔╝   ██║   ╚██████╔╝██████╔╝███████╗██████╔╝███████╗
#       ╚═╝    ╚═════╝  ╚═════╝    ╚═╝    ╚═════╝ ╚═════╝ ╚══════╝╚═════╝ ╚══════╝
                                                                                             
                                                                                                                                                

# To download a video in 720p MP4:
youtube-dl -f 22 example.com/watch?v=id

# To download a video in 720p MP4 or WebM or FLV:
youtube-dl -f 22/45/120

# To list all available formats of a video:
youtube-dl -F example.com/watch?v=id

# To download a video to /$uploader/$date/$title.$ext:
youtube-dl -o '%(uploader)s/%(date)s/%(title)s.%(ext)s' example.com/watch?v=id

# To download a video playlist starting from a certain video:
youtube-dl --playlist-start 5 example.com/watch?v=id&list=listid

# To simulate a download with youtube-dl:
youtube-dl -s example.com/watch?v=id

# Get playlist for Livestream on YouTube
youtube-dl --list-formats <URL>; youtube-dl -f <STREAM_ID> -g <URL>

# Get YT autogen subtitles
youtube-dl --write-auto-sub -f 139 -o subtitles CUdwDEKlDrw; grep '<c.color' subtitles.en.vtt|sed 's/<[^>]\+>//g' 

# For all video formats see
# http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs

# I have a text file with a song and artist on each line. I would like to make a script that would insert each line from the text file, insert it in the command below, and then repeat until the end of the file. edited for clarity
youtube-dl -f 'bestaudio[ext=m4a]' "ytsearch1:INSERT TEXT HERE"

# Try...# This should print out all of your listed items.
while read item; do
  echo "$item"
done < song_list.txt

# Now, alter it by asking it to perform the youtube-dl instead of displaying...
while read item; do
  youtube-dl -f 'bestaudio[ext=m4a]' "ytsearch1:$item"
done < song_list.txt

# D/l from youtube
youtube-dl 'https://www.youtube.com/watch?v=CnDUZCtALWI'

youtubeuploader -title "5 hours of fishbowl" -description "fish, for 5 hours" -limitBetween 09:00-17:00 -ratelimit 2000 -filename fish.webm 
# You've probably heard of youtube-dl. Well there's also youtubeuploader, which can rate limit upload speed.

# Listen to a song from youtube with youtube-dl and mpv - Explanation Firstly the function checks if user gave it any input, and notifies the user if they failed to do so. If user has inputed a search string, the function will call upon youtube-dl to find url of the audio of the first matching youtube video and play that with mpv. Call function by wrapping search string in quotes: listen-to-yt "sultans of swing" You have to paste the line in your .zshrc and source .zshrc for it to work. Limitations The dependancies are youtube-dl and mpv. 
function listen-to-yt() { if [[ -z "$1" ]]; then echo "Enter a search string!"; else mpv "$(youtube-dl --default-search 'ytsearch1:' \"$1\" --get-url | tail -1)"; fi }

    

#==============================##==============================#
# CMD YOUTUBEDL						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░