Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on ffmpeg and avconv.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/ffmpeg.e>
#           or at <http://angg.twu.net/e/ffmpeg.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######




# «.mailing-lists»		(to "mailing-lists")
# «.ffmpeg»			(to "ffmpeg")
# «.screencasts»		(to "screencasts")
# «.script-2012oct»		(to "script-2012oct")
# «.adding-audio»		(to "adding-audio")
# «.avconv-wheezy»		(to "avconv-wheezy")
# «.avconv»			(to "avconv")
# «.avconv-grab»		(to "avconv-grab")
# «.x11grab-problem-erasal»	(to "x11grab-problem-erasal")
# «.recordmydesktop»		(to "recordmydesktop")
# «.audio-quality»		(to "audio-quality")
# «.extract-audio»		(to "extract-audio")
# «.libav-deb-src»		(to "libav-deb-src")
# «.key-frames»			(to "key-frames")
# «.extract-frame»		(to "extract-frame")
# «.dvd-subtitles»		(to "dvd-subtitles")
# «.audio-plus-photos-to-video»	(to "audio-plus-photos-to-video")
# «.mono»			(to "mono")
# «.extract-part-of-mp3»	(to "extract-part-of-mp3")
# «.raising-volume»		(to "raising-volume")
# «.volume-2020»		(to "volume-2020")
# «.libav-git»			(to "libav-git")
# «.cover-picture»		(to "cover-picture")
# «.rotate»			(to "rotate")
# «.rotate-avconv»		(to "rotate-avconv")
# «.vichy-video»		(to "vichy-video")
# «.webm-to-mp4»		(to "webm-to-mp4")
# «.feury-concat»		(to "feury-concat")
#   «.concat-kla»		(to "concat-kla")
# «.feury-cut»			(to "feury-cut")
# «.feury-cut-mnu4»		(to "feury-cut-mnu4")
# «.feury-replace-audio»	(to "feury-replace-audio")
# «.emacsconf2019-25»		(to "emacsconf2019-25")
# «.emacsconf2019-35»		(to "emacsconf2019-35")
# «.emacsconf2019-35end»	(to "emacsconf2019-35end")
# «.non-monotonous-dts»		(to "non-monotonous-dts")
# «.encode-vp9-two-pass»	(to "encode-vp9-two-pass")
# «.ffprobe»			(to "ffprobe")
# «.mediainfo»			(to "mediainfo")
# «.mkvtoolnix»			(to "mkvtoolnix")
# «.audio-to-video»		(to "audio-to-video")
# «.speed-up»			(to "speed-up")
# «.akater-tty-screenshot»	(to "akater-tty-screenshot")
# «.waveform»			(to "waveform")
# «.ffmpeg-buddy»		(to "ffmpeg-buddy")
# «.video-duration»		(to "video-duration")
# «.video-thumbnail»		(to "video-thumbnail")
# «.scale»			(to "scale")
# «.video-to-audio»		(to "video-to-audio")



# (find-es "screencasts")




#####
#
# mailing lists
# 2012nov10
#
#####

# «mailing-lists» (to ".mailing-lists")
# http://ffmpeg.org/pipermail/ffmpeg-user/2012-February/004824.html
# http://ffmpeg.org/pipermail/ffmpeg-user/




#####
#
# ffmpeg
# 2012feb04
#
#####

# «ffmpeg»  (to ".ffmpeg")
# (find-angg "VIDEOS/Makefile")

# (find-status   "ffmpeg")
# (find-vldifile "ffmpeg.list")
# (find-udfile   "ffmpeg/")
# (find-status   "ffmpeg-doc")
# (find-vldifile "ffmpeg-doc.list")
# (find-udfile   "ffmpeg-doc/")
# (find-udfile   "ffmpeg-doc/html/")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
ffmpeg -i DSC_0141.MOV DSC_0141.flv
ffmpeg -i DSC_0142.MOV DSC_0142.flv
ffmpeg -i DSC_0142.MOV -ar 44100 DSC_0142.flv
ffmpeg -i DSC_0142.MOV -ar 44100 -r 6 DSC_0142_6.mov
ffmpeg -i DSC_0142.MOV           -r 6 DSC_0142_6b.mov

cd /tmp/
mplayer DSC_0142.MOV
mplayer DSC_0142_6.MOV

# http://ffmpeg-users.933282.n4.nabble.com/Error-message-video-frame-size-changed-td3314555.html
# (find-fline "/etc/ffserver.conf")

http://ffmpeg.org/faq.html
http://sourceforge.net/projects/ffmpeg-gui/
http://ffmpeg-gui.sourceforge.net/

# (find-man "1 ffmpeg")
# (find-man "1 ffmpeg" "extract images from a video")
# (find-man "1 ffmpeg" "-r fps")
# (find-man "1 ffmpeg" "-f fmt")
# (find-man "1 ffmpeg" "-vsync parameter")
# (find-man "1 ffmpeg" "ffmpeg -f x11grab")
# (find-man "1 ffmpeg" "seek_point, sp")
# (find-man "1 ffmpeg" "-ss position")
# (find-man "1 ffmpeg" "-t duration")
# (find-man "1 ffmpeg" "-b bitrate")
# (find-man "1 ffplay")
# (find-man "1 ffprobe")
# (find-man "1 ffserver")

# (find-sh "ffmpeg -h")
# (find-sh "ffmpeg -formats")
# (find-sh "ffmpeg -formats" "MOV")
# (find-sh "ffmpeg -formats" "h264" "H.264")


ffmpeg-doc

http://www.rumourisnews.com/install_ffmpeg_on_debian.html
http://linuxers.org/tutorial/how-slowdown-or-speed-video-using-ffmpeg-and-yuvfps
http://howto-pages.org/ffmpeg/
http://stackoverflow.com/questions/1555771/which-frame-does-ffmpeg-get-when-reducing-the-frame-rate
http://www.linuxquestions.org/questions/linux-general-1/ffmpeg-dramatic-decrease-in-size-from-camera-videos-660241/
http://answers.yahoo.com/question/index?qid=20080405224044AAq2015
http://canerblt.wordpress.com/2011/07/10/changing-fps-rate-of-a-video-with-ffmpeg/

<edrx> hello - how do I reduce the number of frames of a video? it's
       for recording a conference with few slides and a speaker who
       does not move too much... the camera produced a .mov with 24
       fps, and I'd like to reduce that to 8 fps by keeping only 1 in
       each 3 frames...
<edrx> (btw, I am on debian, and using the command line)
<rypervenche> Hi all. My screencasting script broke a while back,
              apparently due to an update in ffmpeg. It uses x264,
              however at first I record lossless data. I have since
              fixed my script using "-vcodec libx264 -preset
              ultrafast", but is this lossless data? Should I be
              using somethign else?
<rypervenche> Before I was using -vpre lossless_ultrafast. Is there
              still a lossless option or should I only use the
              ultrafast option?



#####
#
# Creating screencasts
# 2012oct27
#
#####

# «screencasts»  (to ".screencasts")
# http://ubuntuguide.org/wiki/Screencasts
# http://wiki.nosdigitais.teia.org.br/Screencast

# (find-man "1 ffmpeg")
# (find-man "1 ffmpeg" "X11 grabbing")
# (find-man "1 ffmpeg" "-s size" "  cif")

ffmpeg -f x11grab -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
ffmpeg -f x11grab -s cif -r 25 -i $DISPLAY /tmp/out.mpg
laf   /tmp/out.mpg
rm -v /tmp/out.mpg
ffmpeg -f x11grab        -r 25 -i $DISPLAY /tmp/out.mpg
laf   /tmp/out.mpg
# (find-video "/tmp/out.mpg")


# (find-angg ".fvwm/.fvwm2rc" "moving-the-cursor")
# (find-man "1 ffmpeg")

* (eepitch-shell12)
* (eepitch-shell)
rm -v /tmp/out.mp*
# sleep 3 &&
ffmpeg -loglevel quiet -f x11grab -s 540x600+0+0 -r 5 -i $DISPLAY /tmp/out.mp4 >& /dev/null
*
* (eepitch-shell)
*  (find-fvwm0 "CursorMove -1000p -1000p")
*  (find-fvwm0 "CursorMove +0 +100")

* (eepitch-shell2)
# (find-angg "eev-videos/video1.sh")
~/eev-videos/video1.sh xterm

* (eepitch-shell2)
killall ffmpeg
killall -9 ffmpeg

* (setq ee-mplayer-options '("-fs" "-title" "mplayer-fullscreen" "-osdlevel" "0"))
* (find-mplayer "/tmp/out.mp4")
* (find-mplayer0 "/tmp/out.mp4")
* (setq ee-mplayer-options '("-fs" "-title" "mplayer-fullscreen" "-osdlevel" "2"))

* (setq ee-mplayer-options '("-fs" "-osdlevel" "2"))


# (find-angg ".emacs" "mplayer-options")




#####
#
# Header for screencast scripts, oct/2012
# 2012oct28
#
#####

# «script-2012oct» (to ".script-2012oct")
# (find-angg "eev-videos/1.sh")
# (find-bashnode "Top")
# (find-bashnode "Bourne Shell Builtins" "`shift'")
# (find-bashnode "Bash Builtins" "`read'" "`-s'")
# (find-es "console" "tput")
# (find-man "5 terminfo" "setaf")
# (find-man "5 terminfo" "setab")
# (find-man "5 terminfo" "COLOR_YELLOW")
# (find-man "5 terminfo" "COLOR_BLUE")
# (find-man "5 terminfo" "COLOR_GREEN")
# (find-man "5 terminfo" "bold")

# Command-line arguments for screencasts
fvwmdown   () { FvwmCommand "CursorMove +0 +100"; }
ffmpeggrab () {
  rm -f /tmp/out.mp4
  nohup ffmpeg -loglevel quiet -f x11grab -i $DISPLAY $* /tmp/out.mp4 \
    > /dev/null 2>&1 &
}
if [[ "$1" == "down"   ]]; then fvwmdown; shift; fi
if [[ "$1" == "ffmpeg" ]]; then ffmpeggrab -r 5 -s $2; shift 2; fi
if [[ "$1" == "xterm"  ]]; then
  G=$2; shift 2; exec xterm -T xterm -geometry $G -e $0 $*
fi

# Colors
C0=$(tput sgr0)
C1=$(tput setaf 3; tput setab 1; tput bold;)
CB=$(tput bold; tput setaf 4)
CG=$(tput setaf 2)

# Sleep, sleep-then-echo, display-prompt-and-command, display-and-eval
slep () { sleep $1; }
slep () { stty -echo; read; stty echo; }
slep () { read -s; }
se   () { read; echo "$2"; }
se   () { echo; slep $1; echo "$2"; }
dpc  () {
  echo -n "${CG}$PWD(edrx)\$${C0} "; slep 1;
  echo -n "$*"; slep 1;
  echo;
}
function de () { dpc "$*"; eval $*; }


* (eepitch-shell2)
* (eepitch-kill)
* (eepitch-shell2)
makeR1C e/ffmpeg.e.html

# http://angg.twu.net/e/ffmpeg.e.html
buffer-file-name
buffer-name





#####
#
# Adding audio to a video
# 2012oct28
#
#####

# «adding-audio» (to ".adding-audio")
# (find-fline "~/eev-videos/")
# (find-man "1 ffmpeg" "-acodec")
# (find-man "1 ffmpeg" "-newaudio")

* (eepitch-shell2)
* (eepitch-kill)
* (eepitch-shell2)
cd ~/eev-videos/
ffmpeg -i 2012oct28-intro-pt.mp4 \
       -i 2012oct28-intro-pt.mp3 \
       -vcodec copy \
       -acodec copy \
       -acodec copy \
       eev-video.mp4 \
       -newaudio




#####
#
# avconv on wheezy
# 2013jun30
#
#####

# «avconv-wheezy» (to ".avconv-wheezy")

# (find-man "1 avconv")
# (find-man "1 avprobe")
# (find-man "1 avserver")
# (find-man "1 avplay")
# (find-man "1 qt-faststart")
# (find-man "1 ffprobe")
# (find-man "1 ffserver")
# (find-man "1 ffplay")






#####
#
# avconv / libav-tools
# 2012nov10
#
#####

# «avconv» (to ".avconv")
# http://packages.debian.org/squeeze-backports/ffmpeg
# http://packages.debian.org/squeeze-backports/libav-tools
# (find-status   "libav-tools")
# (find-vldifile "libav-tools.list")
# (find-udfile   "libav-tools/")
# (find-man "1 avconv")
# (find-man "1 avconv" "X11 grabbing")
# (find-man "1 avconv" "qxga")

# (find-angg "eev-videos/0.sh")
# (find-angg "eev-videos/2.sh")

* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
rm -v /tmp/out.log
rm -v /tmp/out.mp4
source ~/eev-videos/0.sh
ffmpeg-kill
# ffmpeg-grab -s qxga
ffmpeg-grab -s 1024x600
# sleep 10
ffmpeg-kill
# (find-fline "/tmp/")
# (find-fline "/tmp/out.log")
# (find-mplayer "/tmp/out.mp4")

http://backports.debian.org/debian-backports/pool/main/liba/libav/libav_0.8.3-1~bpo60+1.dsc
http://backports.debian.org/debian-backports/pool/main/liba/libav/libav_0.8.3-1~bpo60+1.debian.tar.gz
http://backports.debian.org/debian-backports/pool/main/liba/libav/libav_0.8.3.orig.tar.gz




#####
#
# avconv grab
# 2016oct07
#
#####

# «avconv-grab» (to ".avconv-grab")
# (find-es "x" "screen-dimensions")
# (find-sh0 "xdpyinfo | grep 'dimensions:' | awk '{print $2}'")
# (find-man "1 avconv")
# (find-man "1 avconv" "X11 grabbing")
# (find-man "1 avconv" "qxga" "2048x1536")
# (find-man "1 avconv" "xga 1024x768")
# (find-es "emacs" "adjust-geometry")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
avconv -f x11grab -s 1280x800 -r 5 -i :1.0 /tmp/out.mpg
avconv -f x11grab -i :1.0 /tmp/out.mpg
avconv -f x11grab -s 1280x800 -i :1.0 /tmp/out.mpg
avconv -f x11grab -s 1280x800 -i :1.0 -y /tmp/out.mpg
avconv -f x11grab -s 1280x800 -i :1.0 -y /tmp/out.mp4
# (find-video "/tmp/out.mpg")
# (find-video "/tmp/out.mp4")

* (set-frame-width  nil 167)
* (set-frame-height nil 59)
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
avconv -f x11grab -s xga -i :1.0 -y /tmp/out.mp4
* (message "bcdefg")

# (find-video "/tmp/out.mp4")




#####
#
# x11grab problem with erasals
# 2016oct18
#
#####

# «x11grab-problem-erasal» (to ".x11grab-problem-erasal")
# http://angg.twu.net/eev-videos/x11grab-problem-2016oct18.mp4
# (find-fline "/home/edrx/LOGS/2016oct18.emacs")
# (find-fline "/home/edrx/LOGS/2016oct18.emacs" "<wgreenhouse> edrx:")
# (find-fline "/home/edrx/LOGS/2016oct18.libav")
# (find-fline "/home/edrx/LOGS/2016oct18.libav" "XShmGetImage")
# (find-es "x" "xserver-log")

# (find-zsh "dmissing -i XShmGetImage")
# (find-man "3 XShmGetImage")





#####
#
# recordmydesktop
# 2016oct23
#
#####

# «recordmydesktop» (to ".recordmydesktop")
# http://unix.stackexchange.com/questions/73622/how-to-get-near-perfect-screen-recording-quality

# (find-es "flash" "recordmydesktop")
# (find-es "video" "recordmydesktop")
# (find-man "1 recordmydesktop")

(/ 768 640.0)
(/ 59 1.2)

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
* (size 167 59)
recordmydesktop --display :1.0 -x 0 -y 0 --width 1024 --height 768 --full-shots --fps 5 \
  -o /tmp/out.ogv &

file:///tmp/out.mp4.ogv

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
* (size 167 49)
recordmydesktop --display :1.0 -x 0 -y 0 --width 1024 --height 640 \
  --full-shots --fps 5 \
  -o /tmp/out.ogv &
killall recordmydesktop

# file:///tmp/out.ogv


hello


killall recordmydesktop


Hello






#####
#
# Reducing audio quality with avconv
# 2012nov15
#
#####

# «audio-quality» (to ".audio-quality")
# (find-man "1 avconv")
# (find-man "1 avconv" "-b:a 128k")
# (find-man "1 avconv" "-codec copy")
# (find-man "1 avconv" "avconv -i /tmp/a.wav -ar 22050")
# (find-eev-video-links "2pt")
# (find-fline "~/eev-videos/" "video2pt-")

# (find-fline "~/NICOTINE/Atras_do_porto/" "menino_bonito.mp3")
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cp -v ~/NICOTINE/Atras_do_porto/menino_bonito.mp3 /tmp/a1.mp3
cd /tmp/
avconv -i a1.mp3 -b 64k a2.mp3
avconv -i a2.mp3 -b 32k a3.mp3
# (find-fline "/tmp/")
# (find-TH "html5-audio")
cp -v a3.mp3 ~/TH/L/html5-audio.mp3
Scp-np a3.mp3 $TWUS/html5-audio.mp3



#####
#
# Extracting the audio from a video
# 2017mar12
#
#####

# «extract-audio» (to ".extract-audio")

# (find-fline "/sda5/videos/")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /sda5/videos/
avconv -i David_Bowie_-_Amsterdam-153Abqg7_3I.mp4 -codec copy \
          David_Bowie_-_Amsterdam-153Abqg7_3I.mp3







#####
#
# libav (from the debian sources)
# 2012nov10
#
#####

# «libav-deb-src» (to ".libav-deb-src")
# http://backports.debian.org/debian-backports/pool/main/liba/libav/
# http://backports.debian.org/debian-backports/pool/main/liba/libav/libav_0.8.3-1~bpo60+1.dsc
# http://backports.debian.org/debian-backports/pool/main/liba/libav/libav_0.8.3-1~bpo60+1.diff.gz
# http://backports.debian.org/debian-backports/pool/main/liba/libav/libav_0.8.3.orig.tar.gz
#*
rm -Rv ~/usrc/libav/
mkdir  ~/usrc/libav/
cd $S/http/backports.debian.org/debian-backports/pool/main/liba/libav/
cp -v libav_0.8.3* ~/usrc/libav/
cd     ~/usrc/libav/
dpkg-source -sn -x libav_0.8.3-1~bpo60+1.dsc
cd     ~/usrc/libav/libav-0.8.3/
dpkg-buildpackage -us -uc -b -rfakeroot     |& tee odb

#*
# (find-fline "~/usrc/libav/")
* (eepitch-shell)
cd ~/usrc/libav/
sudo dpkg -i *.deb

#*
# (code-c-d "libav" "~/usrc/libav/libav-0.8.3/")
# (find-libavfile "")
# (find-libavfile "Changelog")
# (find-libavfile "Changelog" "version 0.8_beta1:")

# (find-libavfile "doc/")
# (find-libavgrep "grep -nH -e grab doc/*")




#####
#
# Key frames
# 2012nov17
#
#####

# «key-frames» (to ".key-frames")
# http://en.wikipedia.org/wiki/Key_frame
# http://en.wikipedia.org/wiki/Video_compression_picture_types
# http://libav.org/avconv.html
# http://libav.org/css/bootstrap.css
# http://libav.org/css/libav.css
# http://libav.org/css/alert.css

# (find-man "1 avconv" "-g gop_size" "group of pictures")
# (find-man "1 avconv" "-c:a copy")

# (find-zsh "dmissing avconv.html")

# (find-fline "~/LOGS/2013jan10.libav")
# (defun eejump-9 () (find-2b '(find-es "ffmpeg") '(find-ebuffer "#libav@irc.freenode.net")))

# (find-angg "eev-videos/" "video4-eepitch.mp4")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cp -fv ~/eev-videos/video4-eepitch.mp4 /tmp/a.mp4
cd /tmp/
nice avconv -i /tmp/a.mp4 -g  5 -c:a copy -y /tmp/a-g05.mp4  |& tee a-g05.log
nice avconv -i /tmp/a.mp4 -g 10 -c:a copy -y /tmp/a-g10.mp4  |& tee a-g10.log
laf /tmp/*.mp4

# (find-fline "/tmp/")
# (find-video "/tmp/b.mp4")




#####
#
# dvd subtitles
# 2013feb14
#
#####

# «dvd-subtitles» (to ".dvd-subtitles")
# http://ffmpeg-users.933282.n4.nabble.com/extract-subtiles-td939612.html

# (find-man "1 ffmpeg")
# (find-man "1 avconv")
# (find-man "1 avconv" "-sbsf mov2textsub")
  avconv -i file.mov -an -vn -sbsf mov2textsub -c:s copy -f rawvideo sub.txt

# (find-man "1 avconv" "BITSTREAM FILTERS\n")





#####
#
# Converting audio+photos to video
# 2013jun30
#
#####

# «audio-plus-photos-to-video» (to ".audio-plus-photos-to-video")
# (find-freenode "#libav")
# (find-fline "~/LOGS/2013jun30.libav")
# (find-fline "~/LOGS/2013jun30.libav" "image2pipe")
# http://stackoverflow.com/questions/16315192/avconv-make-a-video-from-a-subset-on-images

# (find-man "1 avconv" "image2pipe")
# Where's avconv in wheezy? =(

# (find-zsh "installeddebs | sort | grep libav")
# (find-zsh "availabledebs | sort | grep libav")

# (find-status   "libav-tools")
# (find-vldifile "libav-tools.list")
# (find-udfile   "libav-tools/")




#####
#
# Creating mono .mp3 files
# 2013aug11
#
#####

# «mono» (to ".mono")
# (find-man "1 ffmpeg" "AUDIO ENCODERS")
# (find-man "1 ffmpeg" "-ac channels")




#####
#
# Extracting a part of an mp3 file
# 2013aug12
#
#####

# «extract-part-of-mp3» (to ".extract-part-of-mp3")
# (find-es "mplayer" "extract-part-of-mp3")
# (find-man "1 ffmpeg" "-ss position")
# (find-man "1 ffmpeg" "-t duration")
# (find-man "1 avconv")
# (find-sh "avconv -formats")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cp -v ~/TH/L/html5-audio.mp3     /tmp/in.mp3
cp -v ~/audios/2013ago01-ict.3ga /tmp/in.3ga
cp -v ~/audios/2013ago01-ict.mp3 /tmp/in2.mp3

cd /tmp/
avconv    -i in.mp3 -ss 0:30 -t 0:35 -y out.mp3
avconv -y -i in.mp3 out.mp3
avconv -y -i in.mp3 -acodec copy out.mp3
avconv -y -i in.mp3 -acodec copy out.mp3
avconv -y -i in.mp3 -acodec copy -ss 30 out.mp3
avconv -y -i in.mp3 -acodec copy -ss 30 -t 5 out.mp3
avconv -y -i in.3ga -acodec copy -ss 1:24:57 -t 7:10 out.3ga
avconv -y -i in.3ga              -ss 1:24:57 -t 430 out.mp3
avconv -y -i in.3ga              -ss 1:24:57 -t 430 -b:a 128k -ac 1 out2.mp3


# «raising-volume» (to ".raising-volume")
avconv -y -i out2.mp3 -b:a 128k -t 20 -ac 1 -filter volume=volume=10dB out3.mp3
avconv -y -i out2.mp3 -b:a 128k -t 20 -ac 1 -vol 80dB out3.mp3
avconv -y -i out2.mp3 -b:a 128k -t 20 -ac 1 -vol 512 out3.mp3
cd /tmp/
avconv -y -i out2.mp3 -b:a 128k -t 20 -ac 1 -vol 1024 out3.mp3
avconv -y -i out2.mp3 -b:a 128k       -ac 1 -vol 1024 out3.mp3
# (find-audio "/tmp/out3.mp3")

# (find-audio "/tmp/out2.mp3")
# (find-audio "/tmp/out3.mp3")

# (find-fline "~/LOGS/2013aug12.libav")
<elenril> anyway, https://libav.org/avconv.html#volume
<edrx> trying...
<edrx> "-filter volume=volume=10dB" ?


cp -v out2.mp3 out3.mp3




#####
#
# extract-frame
# 2023sep11
#
#####

# «extract-frame»  (to ".extract-frame")
# (find-es "imagemagick" "convert")
# https://www.baeldung.com/linux/ffmpeg-extract-video-frames
# https://superuser.com/questions/1009969/how-to-extract-a-frame-out-of-a-video-using-ffmpeg
# (find-man "1 ffmpeg" "-ss position")
# (find-man "1 ffmpeg" "-vframes")
# (find-man "1 ffmpeg" "-frames[:stream_specifier]")
# (find-SUBSfile "mathologer-calculus-easy.lua" "cp -v")
# (find-calceasyvideo "13:00")
# (find-calceasyvideo "16:15")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
STEM=mathologer-calculus-easy
EXT=webm
ECHO=echo
videofile () { echo ${STEM}.${EXT} }
jpgfile   () { echo ${STEM}_${1}.jpg }
pdffile   () { echo ${STEM}_${1}.pdf }
makejpg   () { $ECHO ffmpeg -loglevel error -y -ss $1 -i $(videofile) -frames:v 1 $(jpgfile $1) }
makepdf   () { $ECHO convert -scale 50% $(jpgfile $1) $(pdffile $1) }
makepdf   () { $ECHO convert $(jpgfile $1) $(pdffile $1) }
copypdf   () { $ECHO cp $(pdffile $1) ~/LATEX/2023-2-C2/ }

cd /tmp/
ECHO=echo
ECHO=
for i in 13:00 16:16; do
  makejpg $i
  makepdf $i
  copypdf $i
  echo "(find-latexscan-links \"C2\" \"${STEM}_${i}\")"
done
laf ${STEM}*





#####
#
# Notes on raising the volume (2020)
# 2020nov27
#
#####

# «volume-2020»  (to ".volume-2020")
# https://trac.ffmpeg.org/wiki/AudioVolume
# https://bytefreaks.net/uncategorized/increase-volume-in-video-using-ffmpeg
# https://blog.programster.org/change-audio-level-in-video
# (code-eevvideo "eev2020p1" "eev2020part1")
# (find-eev2020p1video "0:00")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cp -iv $S/http/angg.twu.net/eev-videos/eev2020part1.mp4 /tmp/video0.mp4

cd /tmp/
ffmpeg \
  -i video0.mp4 \
  -vcodec copy \
  -af "volume=30dB" \
  video1.mp4

# (find-video "/tmp/video0.mp4")
# (find-video "/tmp/video1.mp4")




#####
#
# libav from git
# 2013aug12
#
#####

# «libav-git» (to ".libav-git")
# http://www.libav.org/download.html
# git://git.libav.org/libav.git

* (eepitch-shell2)
* (eepitch-kill)
* (eepitch-shell2)
# (find-fline "~/bigsrc/")
cd ~/bigsrc/
git clone --depth 1 git://git.libav.org/libav.git

cd ~/bigsrc/libav/
./configure   |& tee oc
make          |& tee om

(code-c-d "libav" "~/bigsrc/libav/")
;; (find-libavfile "")
# (find-fline "~/bigsrc/libav/")




#####
#
# Cover picture
# 2014may13
#
#####

# «cover-picture» (to ".cover-picture")
# http://stackoverflow.com/questions/14423647/ffmpeg-remove-cover-picture-from-mp3-convert-to-ogg-without-cover
# (find-man "1 ffmpeg")




#####
#
# rotate
# 2015jan30
#
#####

# «rotate» (to ".rotate")
# http://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg
# (find-man "1 ffmpeg")
# (find-man "1 ffmpeg" "transpose")
# (find-man "1 ffmpeg" "hflip")
# (find-man "1 ffmpeg" "vflip")
# (find-man "1 ffmpeg" "  vflip")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
rm -v output.mp4
# ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
# ffmpeg -vfilters "rotate=90" -i input.mp4 output.mp4
# ffmpeg -vf "rotate=90" -i input.mp4 output.mp4
# ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
# rm -v output.mp4
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4; # 90 degrees clockwise
ffmpeg -i input.mp4 -vf "transpose=2" output.mp4; # 90 degrees counterclockwise

ffmpeg -i input.mp4 -vf "hflip,vflip" output.mp4; # 180 degrees

# (find-video "/tmp/input.mp4")
# (find-video "/tmp/output.mp4")

# (find-sh "ffmpeg -filters")
# (find-man "ffmpeg")
# (find-man "ffmpeg" "  transpose")



# (find-video "/tmp/output.mp4")
# (find-man "mplayer2")





#####
#
# rotate a video with avconv
# 2016sep07
#
#####

# «rotate-avconv» (to ".rotate-avconv")
# http://stackoverflow.com/questions/25031557/rotate-mp4-videos-without-re-encoding
# (find-sh "ls /tmp/*.mp4")
# (to "avconv-wheezy")
# (to "avconv")
# (find-man "1 avconv")
# (find-man "1 avprobe")
# https://libav.org/avconv.html
# https://libav.org/avconv.html#transpose
# https://wiki.libav.org/Encoding/aac

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
STEM=20160907_casa_e_lana
avprobe -v quiet $STEM.mp4 -show_streams
avprobe -v quiet $STEM.mp4 -show_streams | grep rot
avconv -i $STEM.mp4 -c copy -metadata:s:v:0 rotate=0  ${STEM}_0.mp4
avconv -i $STEM.mp4 -c copy -metadata:s:v:0 rotate=90 ${STEM}_90.mp4
avconv -i $STEM.mp4 -vf "transpose=clock" ${STEM}_90.mp4

for i in $STEM*.mp4 do
  echo $i:
  avprobe -v quiet $STEM.mp4 -show_streams | grep rot
done

# ^ Not working... how can I play a video in a different orientation?

# (find-man "1 mplayer2")
# (find-man "1 mplayer2" "rotate[=<0-7>]")

# (defvar     ee-mplayer-options '("-fs" "-osdlevel" "2" "-zoom"))

(let ((ee-mplayer-options `("-vf" "rotate=1" ,@ee-mplayer-options)))
  ee-mplayer-options)

(let ((ee-mplayer-options `("-vf" "rotate=1" ,@ee-mplayer-options)))
  (find-video "/tmp/20160907_casa_e_lana.mp4"))

cd /tmp/
mplayer /tmp/20160907_casa_e_lana.mp4
mplayer -vf rotate=1 /tmp/20160907_casa_e_lana.mp4




#####
#
# Record the video about "Logic for Children" in Vichy
# 2018mai18
#
#####

# «vichy-video» (to ".vichy-video")
# (find-man "1 avconv")
# (find-man "1 avconv" "Video Options")
# (find-man "1 avconv" "Video Options" " -s")
# (find-man "1 avconv" "# Grab at position 10,20")
# (vivp)
# (viv)

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -v /tmp/out.mpg
rm -v /tmp/out.mp4
# { sleep 1; avconv -f x11grab -s 1280x800 -i :1.0       /tmp/out.mp4; } &
  { sleep 1; avconv -f x11grab -s 1000x800 -i :1.0+140,0 /tmp/out.mp4; } &
xpdf -fullscreen ~/LATEX/2018vichy-video.pdf; killall avconv
laf /tmp/out.mp4

# (find-fline "/tmp/" "out.mp4")
# (find-video "/tmp/out.mp4")
* (find-video "/tmp/out.mp4")




#####
#
# Converting webm to mp4
# 2019sep01
#
#####

# «webm-to-mp4» (to ".webm-to-mp4")
# https://blog.addpipe.com/converting-webm-to-mp4-with-ffmpeg/
# https://askubuntu.com/questions/323944/convert-webm-to-other-formats
# https://linuxconfig.org/master-your-videos-from-the-cli-with-ffmpeg
# (find-fline "~/eev-videos/")
# (find-fline "~/eev-videos/" "three-keys-1-pt-video.webm")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/webmtomp4/")
rm -Rv /tmp/webmtomp4/
mkdir  /tmp/webmtomp4/
cd     /tmp/webmtomp4/
cp -iv ~/eev-videos/three-keys-1-pt-video.webm ./video.webm
time ffmpeg -i video.webm video.mp4





#####
#
# Donald Feury - Concatenate Videos Together Using FFMPEG!
# 2020nov22
#
#####

# «feury-concat»  (to ".feury-concat")
# https://dev.to/dak425/concatenate-videos-together-using-ffmpeg-2gg1
# https://www.youtube.com/watch?v=qjumeCB1iEg
# (find-youtubedl-links "/sda5/videos/" "Automated Video Editing - How to Combine Videos Together with ffmpeg" "qjumeCB1iEg" ".mkv" "feuryconcat")
# (code-video "feuryconcatvideo" "/sda5/videos/Automated Video Editing - How to Combine Videos Together with ffmpeg-qjumeCB1iEg.mkv")
# (find-feuryconcatvideo)
# (find-feuryconcatvideo "0:00")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "$S/http/angg.twu.net/eev-videos/")

cd /tmp/
rm -fv video1.mp4 video2.mp4 vlist.txt out.mp4

cd $S/http/angg.twu.net/eev-videos/
cp -v 2020_C2_2020nov09.mp4     /tmp/video1.mp4
cp -v 2020_int_pots_sen_cos.mp4 /tmp/video2.mp4
cat > /tmp/vlist.txt <<'%%%'
file 'video1.mp4'
file 'video2.mp4'
%%%

cd /tmp/
ffmpeg -f concat -i vlist.txt -c copy out.mp4
# (find-video "/tmp/out.mp4")
# (find-video "/tmp/out.mp4" "3:58")




#####
#
# concat-kla
# 2022dec03
#
#####

# «concat-kla»  (to ".concat-kla")
# (find-fline "~/KLA-VIDEOS/")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cat > /tmp/vlist.txt <<'%%%'
file 'ssr-1.mp4'
file 'ssr-2.mp4'
file 'ssr-3.mp4'
file 'ssr-4.mp4'
file 'ssr-5.mp4'
%%%
cd /tmp/
ffmpeg -f concat -i vlist.txt -c copy out.mp4

cd /tmp/
ssr-1.mp4



#####
#
# feury-cut
# 2020dec05
#
#####

# «feury-cut»  (to ".feury-cut")
# https://dev.to/dak425/cut-up-video-and-audio-with-just-ffmpeg-4l4m
# https://www.youtube.com/watch?v=Q2Wc-cDFixs
# (find-youtubedl-links "/sda5/videos/" nil "Q2Wc-cDFixs" nil "feurycut")
# (code-video "feurycutvideo" "/sda5/videos/How_cut_videos_into_clips_using_ffmpeg-Q2Wc-cDFixs.mp4")
# (find-feurycutvideo)
# (find-feurycutvideo "0:00")
# (find-feurycutvideo "1:10")
# (find-feurycutvideo "3:40" "I want the middle portion")
# (find-feurycutvideo "4:14" "instead of a duration a stop timestamp")
# (find-feurycutvideo "5:05" "-to")
# (find-feurycutvideo "6:15" "audio files")
# (find-feurycutvideo "8:45" "add pieces of video and audio files")
# (find-feurycutvideo "9:55" "start reading the file at")
# (find-feurycutvideo "10:30" "ffmpeg -ss ___ -i ___.mp4")
# (find-feurycutvideo "11:22" "a bit confusing if")
# (find-feurycutvideo "11:50" "ffmpeg -ss ___ -i ___.mp4 -t ___ ")
# (find-feurycutvideo "12:00" "ffmpeg -ss ___ -i ___.mp4 -to ___ ")

# (find-man "1 ffmpeg")
# (find-man "1 ffmpeg" "-ss position")
# (find-man "1 ffmpeg" "-t duration")
# (find-man "1 ffmpeg" "-to position")

ffmpeg -i input.mp4 -t 8 -c copy



# (find-1stclassvideo-links "2021workshop3")
# (find-angg ".emacs.videos" "2021workshop3")
# (find-2021workshop3video "4:55" "A demo. In this demo")

# Not working well:

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rv /tmp/ffmpeg/
mkdir  /tmp/ffmpeg/
cd     /tmp/ffmpeg/
cp -v $S/http/angg.twu.net/eev-videos/2021-workshop-3.mp4 in.mp4

ffmpeg -ss 4:55 -i in.mp4 -c copy out.mp4
# (find-video "/tmp/ffmpeg/out.mp4")



#####
#
# Cutting a part of a video (mnu4)
# 2022jul23
#
#####

# «feury-cut-mnu4»  (to ".feury-cut-mnu4")
# (find-es "ead" "mat-na-univ-4-eu")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
INPUT=/home/videos/Math/Matematica_na_Universidade_-_Reuniao_4_-_11-6-2021-kvfv6fnNTng.mkv
cp -v $INPUT /tmp/ffmpeg-input.mkv

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -fv /tmp/ffmpeg-output.mkv
ffmpeg -ss 35:00 -to 1:25:35 -i /tmp/ffmpeg-input.mkv -c copy /tmp/ffmpeg-output.mkv

# (find-video "/tmp/ffmpeg-output.mkv")

# (find-mnu4video   "35:00" "Eduardo Ochs")
# (find-mnu4video "1:25:36" "Márcio Adames")

Minha apresentação na reunião 4 do "Matemática na Universidade", em 11/jun/2021.
A versão integral da reunião está em: http://www.youtube.com/watch?v=kvfv6fnNTng
O trecho deste vídeo começa no 35:00 na versão integral.
Mais informações aqui: http://angg.twu.net/2021aulas-por-telegram.html



Matemática na Universidade - Reunião 4 - 11/jun/2021 - Eduardo Ochs





#####
#
# feury-replace-audio
# 2020dec05
#
#####

# «feury-replace-audio»  (to ".feury-replace-audio")
# https://dev.to/dak425/how-to-replace-the-audio-in-a-video-with-the-audio-from-another-video-with-ffmpeg-2ob8
# https://www.youtube.com/watch?v=fXdaNnAe_MA
# (find-youtubedl-links "/sda5/videos/" "Automated_Video_Editing_-_How_to_replace_the_audio_in_a_video_with_ffmpeg_feurious" "fXdaNnAe_MA" ".mkv" "feuryreplace")
# (code-video "feuryreplacevideo" "/sda5/videos/Automated_Video_Editing_-_How_to_replace_the_audio_in_a_video_with_ffmpeg_feurious-fXdaNnAe_MA.mkv")
# (find-feuryreplacevideo "0:00")
# (find-feuryreplacevideo "2:25" "overcomplicated way")
# (find-feuryreplacevideo "3:51" "how do we merge them")
# (find-feuryreplacevideo "4:05" "merged-separate.mkv")

# (find-man "1 ffmpeg")
# (find-man "1 ffmpeg" "-an (output)")




#####
#
# Remaking the "ZOOM0025" video of my EmacsConf2019 talk with ffmpeg
# 2020dec05
#
#####

# «emacsconf2019-25»  (to ".emacsconf2019-25")
# (find-fline "/sda5/home/edrx/eev-videos/emacsconf/")
# (find-fline "/sda5/home/edrx/eev-videos/emacsconf/ZOOM0025.txt")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)

* (eepitch-vterm)
* (eepitch-kill)
* (eepitch-vterm)
rm -Rv /tmp/emacsconf2019/
mkdir  /tmp/emacsconf2019/
cd /sda5/home/edrx/eev-videos/emacsconf/
laf --full-time
laf --full-time ZOOM0025*
cp -iv ZOOM0025_audio.wav /tmp/emacsconf2019/
cp -iv ZOOM0025_video.mp4 /tmp/emacsconf2019/


#         to 160Kbps mp3           AUDIOSKIP
# AUDIO0 ----------------> AUDIO1 -----------> AUDIO2
#                                                     \
#                                                      >--> BOTH
#          to mp4 (nop)            VIDEOSKIP          /
# VIDEO0 ----------------> AUDIO1 -----------> VIDEO2
# 
#
cd     /tmp/emacsconf2019/
laf
AUDIO0=/tmp/emacsconf2019/ZOOM0025_audio.wav
AUDIO1=/tmp/emacsconf2019/ZOOM0025_audio1.mp3
AUDIO2=/tmp/emacsconf2019/ZOOM0025_audio2.mp3
VIDEO1=/tmp/emacsconf2019/ZOOM0025_video.mp4
VIDEO2=/tmp/emacsconf2019/ZOOM0025_video2.mp4
JOINED=/tmp/emacsconf2019/ZOOM0025_joined.mp4

makeaudio1 () { ffmpeg -i $AUDIO0 -b:a 160k -y $AUDIO1 }
makeaudio2 () { ffmpeg -ss $AUDIOSKIP -i $AUDIO1 -c copy -t $LEN    -y $AUDIO2 }
makevideo2 () { ffmpeg -ss $VIDEOSKIP -i $VIDEO1 -c copy -t $LEN    -y $VIDEO2 }
makejoined () { ffmpeg     -i $AUDIO2 -i $VIDEO2 -c copy            -y $JOINED }

makeaudio1

AUDIOSKIP=0:07.30
VIDEOSKIP=0:09.60
LEN=30
LEN=13:10

makeaudio2
makevideo2
makejoined

laf

# (find-audio "/tmp/emacsconf2019/ZOOM0025_audio2.mp3")
# (find-video "/tmp/emacsconf2019/ZOOM0025_video2.mp4")
# (find-video "/tmp/emacsconf2019/ZOOM0025_joined.mp4")
# (find-video "/tmp/emacsconf2019/ZOOM0025_joined.mp4" "0:13")
# (find-video "/tmp/emacsconf2019/ZOOM0025_joined.mp4" "13:00")




#####
#
# Remaking the "ZOOM0035" video of my EmacsConf2019 talk with ffmpeg
# 2020dec05
#
#####

# «emacsconf2019-35»  (to ".emacsconf2019-35")
# (find-fline "/sda5/home/edrx/eev-videos/emacsconf/")
# (find-fline "/sda5/home/edrx/eev-videos/emacsconf/ZOOM0025.txt")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)

* (eepitch-vterm)
* (eepitch-kill)
* (eepitch-vterm)
rm -Rv /tmp/emacsconf2019/
mkdir  /tmp/emacsconf2019/
cd /sda5/home/edrx/eev-videos/emacsconf/
laf --full-time
laf --full-time ZOOM0035*
cp -iv ZOOM0035_audio.wav /tmp/emacsconf2019/
cp -iv ZOOM0035_video.mp4 /tmp/emacsconf2019/


#         to 160Kbps mp3           AUDIOSKIP
# AUDIO0 ----------------> AUDIO1 -----------> AUDIO2
#                                                     \
#                                                      >--> BOTH
#          to mp4 (nop)            VIDEOSKIP          /
# VIDEO0 ----------------> AUDIO1 -----------> VIDEO2
# 
#
cd     /tmp/emacsconf2019/
laf
AUDIO0=/tmp/emacsconf2019/ZOOM0035_audio.wav
AUDIO1=/tmp/emacsconf2019/ZOOM0035_audio1.mp3
AUDIO2=/tmp/emacsconf2019/ZOOM0035_audio2.mp3
VIDEO1=/tmp/emacsconf2019/ZOOM0035_video.mp4
VIDEO2=/tmp/emacsconf2019/ZOOM0035_video2.mp4
JOINED=/tmp/emacsconf2019/ZOOM0035_joined.mp4

makeaudio1 () { ffmpeg                -i $AUDIO0 -b:a 160k        -y $AUDIO1 }
makeaudio2 () { ffmpeg -ss $AUDIOSKIP -i $AUDIO1 -c copy -t $LEN  -y $AUDIO2 }
makevideo2 () { ffmpeg -ss $VIDEOSKIP -i $VIDEO1 -c copy -t $LEN  -y $VIDEO2 }
makejoined () { ffmpeg     -i $AUDIO2 -i $VIDEO2 -c copy          -y $JOINED }

makeaudio1

AUDIOSKIP=0:11.50
VIDEOSKIP=0:13.50
LEN=6:04

makeaudio2
makevideo2
makejoined

laf

# (find-audio "/tmp/emacsconf2019/ZOOM0035_audio1.mp3" "1:01" "manpage")
# (find-audio "/tmp/emacsconf2019/ZOOM0035_audio1.mp3" "1:03" "(click)")
# (find-audio "/tmp/emacsconf2019/ZOOM0035_audio2.mp3" "0:50" "manpage")
# (find-video "/tmp/emacsconf2019/ZOOM0035_video.mp4"  "1:05" "manpage")
# (find-video "/tmp/emacsconf2019/ZOOM0035_video2.mp4")
# (find-video "/tmp/emacsconf2019/ZOOM0035_joined.mp4")
# (find-video "/tmp/emacsconf2019/ZOOM0035_joined.mp4" "0:50" "manpage")
# (find-video "/tmp/emacsconf2019/ZOOM0035_joined.mp4" "6:00")




#####
#
# Remaking the "ZOOM0035end" video of my EmacsConf2019 talk with ffmpeg
# 2020dec05
#
#####

# «emacsconf2019-35end»  (to ".emacsconf2019-35end")
# (find-fline "/sda5/home/edrx/eev-videos/emacsconf/")
# (find-fline "/sda5/home/edrx/eev-videos/emacsconf/ZOOM0025.txt")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)

* (eepitch-vterm)
* (eepitch-kill)
* (eepitch-vterm)
rm -Rv /tmp/emacsconf2019/
mkdir  /tmp/emacsconf2019/
cd /sda5/home/edrx/eev-videos/emacsconf/
laf --full-time
laf --full-time ZOOM0035end*
# cp -iv ZOOM0035end_audio.wav /tmp/emacsconf2019/
  cp -iv ZOOM0035end_video.mp4 /tmp/emacsconf2019/


#         to 160Kbps mp3           AUDIOSKIP
# AUDIO0 ----------------> AUDIO1 -----------> AUDIO2
#                                                     \
#                                                      >--> BOTH
#          to mp4 (nop)            VIDEOSKIP          /
# VIDEO0 ----------------> AUDIO1 -----------> VIDEO2
# 
#
cd     /tmp/emacsconf2019/
laf
#AUDIO0=/tmp/emacsconf2019/ZOOM0035end_audio.wav
#AUDIO1=/tmp/emacsconf2019/ZOOM0035end_audio1.mp3
#AUDIO2=/tmp/emacsconf2019/ZOOM0035end_audio2.mp3
VIDEO1=/tmp/emacsconf2019/ZOOM0035end_video.mp4
VIDEO2=/tmp/emacsconf2019/ZOOM0035end_video2.mp4
JOINED=/tmp/emacsconf2019/ZOOM0035end_joined.mp4

makeaudio1 () { ffmpeg                -i $AUDIO0 -b:a 160k        -y $AUDIO1 }
makeaudio2 () { ffmpeg -ss $AUDIOSKIP -i $AUDIO1 -c copy -t $LEN  -y $AUDIO2 }
makevideo2 () { ffmpeg -ss $VIDEOSKIP -i $VIDEO1 -c copy -t $LEN  -y $VIDEO2 }
makejoined () { ffmpeg     -i $AUDIO2 -i $VIDEO2 -c copy          -y $JOINED }

#makeaudio1

#AUDIOSKIP=0:11.50
VIDEOSKIP=0:06
LEN=0:05.50

#makeaudio2
makevideo2
#makejoined

laf

# (find-video "/tmp/emacsconf2019/ZOOM0035end_video.mp4")
# (find-video "/tmp/emacsconf2019/ZOOM0035end_video2.mp4")

cd /tmp/emacsconf2019/
cat > vlist.txt <<'%%%'
file 'ZOOM0025_joined.mp4'
file 'ZOOM0035_joined.mp4'
file 'ZOOM0035end_video2.mp4'
%%%

ffmpeg -f concat -i vlist.txt -c copy -y emacsconf2019_0.mp4
ffmpeg -i emacsconf2019_0.mp4 -c copy -y emacsconf2019.mp4
cmp       emacsconf2019_0.mp4            emacsconf2019.mp4
# (find-video "/tmp/emacsconf2019/emacsconf2019_0.mp4")
# (find-video "/tmp/emacsconf2019/emacsconf2019.mp4")
# (find-fline "/tmp/emacsconf2019/" "emacsconf2019.mp4")

# (find-twusfile "eev-videos/")
# (find-twupfile "eev-videos/")
# (find-fline "/tmp/emacsconf2019/")
cd /tmp/emacsconf2019/
Scp-np emacsconf2019.mp4 $TWUP/eev-videos/emacsconf2019.mp4
Scp-np emacsconf2019.mp4 $TWUS/eev-videos/emacsconf2019.mp4
# (find-eevvideo-links "ec2019" "emacsconf2019" "86yiRG8YJD0" "0:00")




#####
#
# non-monotonous-dts
# 2020dec06
#
#####

# «non-monotonous-dts»  (to ".non-monotonous-dts")
# https://video.stackexchange.com/questions/15468/non-monotonous-dts-on-concat-ffmpeg
# (find-man "ffmpeg")




#####
#
# encode-vp9-two-pass (thanks to Amin Bandali)
# 2020dec06
#
#####

# «encode-vp9-two-pass»  (to ".encode-vp9-two-pass")
# https://emacsconf.org/2019/talks/27/
# https://trac.ffmpeg.org/wiki/Encode/VP9#twopass
#
# Amin: I converted them to vp9+opus webm using a two-pass approach
# mentioned on https://trac.ffmpeg.org/wiki/Encode/VP9#twopass like so:

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rv /tmp/emacsconf2019-vp9/
mkdir  /tmp/emacsconf2019-vp9/
cd     /tmp/emacsconf2019-vp9/
cp -iv /tmp/emacsconf2019/emacsconf2019.mp4 /tmp/emacsconf2019-vp9/input.mp4
# (find-fline  "/tmp/emacsconf2019/")
# (find-fline  "/tmp/emacsconf2019-vp9/")
# (find-sh "cat /tmp/emacsconf2019-vp9/ffmpeg2pass-0.log | tr / '\\n'")

ffmpeg -i input.mp4 -c:v libvpx-vp9 -row-mt 1 -b:v 2M -pass 1 -an -f null /dev/null
ffmpeg -i input.mp4 -c:v libvpx-vp9 -row-mt 1 -b:v 2M -pass 2 -c:a libopus output.webm





#####
#
# ffprobe
# 2021jun16
#
#####

# «ffprobe»  (to ".ffprobe")
# (find-man "1 ffprobe")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
FNAME=$S/http/angg.twu.net/eev-videos/2021-1-C2-intro.mp4
file      $FNAME
mediainfo $FNAME
mediainfo --Full $FNAME
ffprobe   $FNAME







#####
#
# mediainfo
# 2021jun16
#
#####

# «mediainfo»  (to ".mediainfo")
# (find-status   "mediainfo")
# (find-vldifile "mediainfo.list")
# (find-udfile   "mediainfo/")
# (find-man "1 mediainfo")
# (find-sh "mediainfo --Help")




#####
#
# mkvtoolnix
# 2021nov17
#
#####

# «mkvtoolnix»  (to ".mkvtoolnix")
# (find-status   "mkvtoolnix")
# (find-vldifile "mkvtoolnix.list")
# (find-udfile   "mkvtoolnix/")
# https://mkvtoolnix.download/index.html

O arquivo final é mp4 ou mkv?

Se gravou com OBS e gerou um mkv para depois editar pode corrigir
antes da edição e renderizar novamente.

Senão pode usar para um arquivo mkv:

mkvmerge -o destino.mkv -y 1:100 origem.mkv 




#####
#
# audio-to-video
# 2023jul10
#
#####

# «audio-to-video»  (to ".audio-to-video")
# https://superuser.com/questions/1041816/combine-one-image-one-audio-file-to-make-one-video-using-ffmpeg?newreg=d9fd42d1386d4487a128c62307a64a67
# https://www.bannerbear.com/blog/how-to-convert-audio-to-video-for-youtube-upload-using-ffmpeg/
# https://github.com/hniksic/img2video

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
ffmpeg -r 1 -loop 1 -i a.jpg -i a.mp3 -acodec copy -r 1 -shortest -vf scale=1280:720 b.mp4




#####
#
# speed-up
# 2021dec03
#
#####

# «speed-up»  (to ".speed-up")
# https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video

# The speed of a video stream can be changed by changing the
# presentation timestamp (PTS) of each video frame. This can be done
# via two methods: using the ​setpts video filter (which requires
# re-encoding) or by erasing the timestamps by exporting the video to
# a raw bitstream format and muxing to a container while creating new
# timestamps.
#
# Note that in the following examples, the audio stream is not
# changed, so it should ideally be disabled with -an.
#
# raw bitstream method
# --------------------
# This method is lossless and apart from changing the timestamps,
# copies the video stream as-is. Use this if you require no other
# changes to your input video.

First, copy the video to a raw bitstream format.

# For H.264:

ffmpeg -i input.mp4 -map 0:v -c:v copy -bsf:v h264_mp4toannexb raw.h264

# For H.265:

ffmpeg -i input.mp4 -map 0:v -c:v copy -bsf:v hevc_mp4toannexb raw.h265

# Then generate new timestamps while muxing to a container:

ffmpeg -fflags +genpts -r 30 -i raw.h264 -c:v copy output.mp4

# Change the value of -r to the desired playback frame rate.


# setpts filter
#
# To double the speed of the video with the setpts filter, you can
# use:

ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv

# The filter works by changing the presentation timestamp (PTS) of
# each video frame. For example, if there are two succesive frames
# shown at timestamps 1 and 2, and you want to speed up the video,
# those timestamps need to become 0.5 and 1, respectively. Thus, we
# have to multiply them by 0.5.
#
# Note that this method will drop frames to achieve the desired speed.
# You can avoid dropped frames by specifying a higher output frame
# rate than the input. For example, to go from an input of 4 FPS to
# one that is sped up to 4x that (16 FPS):

ffmpeg -i input.mkv -r 16 -filter:v "setpts=0.25*PTS" output.mkv

# To slow down your video, you have to use a multiplier greater than 1:

ffmpeg -i input.mkv -filter:v "setpts=2.0*PTS" output.mkv




#####
#
# akater-tty-screenshot
# 2023jul16
#
#####

# «akater-tty-screenshot»  (to ".akater-tty-screenshot")
# (find-telegachat "@emacs_telega#40524")
# (find-telegachat "@emacs_telega#40524" "akater-tty-screenshot")

(defun akater-tty-screenshot ()
  (interactive)
  (let ((default-directory "~"))
    (shell-command
     "ffmpeg -f fbdev -framerate 1 -i /dev/fb0 -frames:v 1 -q:v 1
     screenshot.jpg")))




#####
#
# waveform
# 2023aug13
#
#####

# «waveform»  (to ".waveform")
# (find-es "subtitles" "waveform-test-2")




#####
#
# ffmpeg-buddy
# 2023sep06
#
#####

# «ffmpeg-buddy»  (to ".ffmpeg-buddy")
# https://news.ycombinator.com/item?id=31557809 Ffmpeg Buddy (evanhahn.github.io)
# https://evanhahn.github.io/ffmpeg-buddy/
# https://github.com/EvanHahn/ffmpeg-buddy




#####
#
# video-duration
# 2023sep25
#
#####

# «video-duration»  (to ".video-duration")
# (find-angg ".zshrc" "video-duration")
# https://superuser.com/questions/650291/how-to-get-video-duration-in-seconds

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
ffprobe \
  -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 \
  VID-20230923-WA0167.mp4




#####
#
# video-thumbnail
# 2023sep25
#
#####

# «video-thumbnail»  (to ".video-thumbnail")
# https://stackoverflow.com/questions/27145238/create-thumbnail-from-video-using-ffmpeg
# https://networking.ringofsaturn.com/Unix/extractthumbnail.php




#####
#
# scale
# 2024mar21
#
#####

# «scale»  (to ".scale")
# (find-man "1 ffmpeg-scaler")
# (find-man "1 ffmpeg")
# (find-man "1 ffmpeg" "scale")
# (find-man "1 ffmpeg" "bufsize")
# (find-man "1 ffmpeg" "-b:v 64k -bufsize 64k")
# https://trac.ffmpeg.org/wiki/Scaling
# (find-fline "$S/http/anggtwu.net/eev-videos/" "emacsconf2021.mp4")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cp -v $S/http/anggtwu.net/eev-videos/emacsconf2021.mp4 /tmp/input.mp4
cd /tmp/
ffprobe input.mp4
ffmpeg -i input.mp4 -vf scale=320:200 output.mp4
ffmpeg -i input.mp4 -sws_flags fast_bilinear -vf scale=320:200 output.mp4
laf input.mp4 output.mp4

ffmpeg -i input.mp4 -vcodec libx265 -crf 28 fps-fps=30 -vf scale=320:200 output.mp4
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 -vf scale=320:200 output.mp4
ffmpeg -i input.mp4  -b:v 64k -bufsize 64k -vf scale=320:200 output.mp4
ffmpeg -i input.mp4  -b:v 32k -bufsize 32k -vf scale=320:200 output.mp4
ffmpeg -i input.mp4  -b:v 16k -bufsize 16k -vf scale=320:200 output.mp4


ffmpeg -i input.jpg -vf scale=320:-1 output_320.png
ffmpeg -i input.jpg -sws_flags fast_bilinear -vf scale=320:-1 output_320.png

# (find-fline "/tmp/")



#####
#
# video-to-audio
# 2024apr16
#
#####

# «video-to-audio»  (to ".video-to-audio")
# https://stackoverflow.com/questions/9913032/how-can-i-extract-audio-from-video-with-ffmpeg/36324719#36324719
# (find-extra-file-links "/sda1/home/music/panda/DAVID_BOWIE/criminal_world.mp3" "{c}")
# (find-audio "/sda1/home/music/panda/DAVID_BOWIE/criminal_world.mp3")
# (find-youtubedl-links "/tmp/" "{title}" "oUbLegcKgIc" "{ext-}" "{stem}")

* (sh-mode)
* (eepitch-shell2)
* (eepitch-kill)
* (eepitch-shell2)
# http://www.youtube.com/watch?v=oUbLegcKgIc
# http://www.youtube.com/watch?v=oUbLegcKgIc#t=0m00s
# http://www.youtube.com/watch?v=oUbLegcKgIc#t=0h00m00s
cd /tmp/
youtube-dl -t -f 18 --restrict-filenames 'http://www.youtube.com/watch?v=oUbLegcKgIc'

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
ffmpeg -i Criminal_World_2018_Remaster-oUbLegcKgIc.mp4 \
  -q:a 0 -map a \
  "David Bowie - Criminal World.mp3"

;; (find-audio "/tmp/David Bowie - Criminal World.mp3")









* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)

# (find-sh "cd /tmp/; ls *.mp4")
INPUTS=(
  c2luc1.mp4
  c2luc2.mp4
)
OUTFILE=2022jul10-apresentacao-C2.mp4

cd /tmp/
for i in $INPUTS; do echo "file '$i'"; done
for i in $INPUTS; do echo "file '$i'"; done > /tmp/vlist.txt
ffmpeg -f concat -i vlist.txt -c copy $OUTFILE

2022jul10-apresentacao-C2.mp4

# (find-video "/tmp/c2luc-all.mp4")
# (find-video "/tmp/out.mp4" "3:58")

# (find-ssr-links "2022c2apr1" "2022jul10-apresentacao-C2" "{hash}" "{time}")





https://trac.ffmpeg.org/wiki/Encode/MP3
https://trac.ffmpeg.org/wiki/Capture/Desktop
https://leixiaohua1020.github.io/#ffmpeg-development-examples
https://trac.ffmpeg.org/wiki/ExtractSubtitles
https://trac.ffmpeg.org/wiki/FFprobeTips





# (find-man "mpv")
# (find-man "mpv" ".      Step forward")
# (find-man "ffmpeg")
# (find-man "ffmpeg" "-ar")
# (find-man "ffmpeg" "-b:a 128k")










https://unix.stackexchange.com/questions/113695/gif-screencasting-the-unix-way





http://blog.pkh.me/p/13-the-ffmpeg-libav-situation.html

# (find-fline "/tmp/" "in.mp3")

(ee-to-seconds "7:10")

# (find-status   "mp3gain")
# (find-vldifile "mp3gain.list")
# (find-udfile   "mp3gain/")
# (find-udfile   "mp3gain/README.method")
# (find-status   "normalize-audio")
# (find-vldifile "normalize-audio.list")
# (find-udfile   "normalize-audio/")

# (find-udfile "normalize-audio/changelog.gz")
# (find-udfile "normalize-audio/README.gz")
# (find-udfile "normalize-audio/TODO")
# (find-udfile "normalize-audio/changelog.Debian.gz")
# (find-udfile "normalize-audio/copyright")
# (find-udfile "normalize-audio/README.Debian")
# (find-man "1 normalize-mp3")
# (find-man "1 normalize-audio")
# (find-fline "/usr/bin/normalize-ogg")
# (find-man "1 normalize-ogg")


normalize-audio

# (find-udfile "mp3gain/changelog.Debian.gz")
# (find-udfile "mp3gain/copyright")
# (find-udfile "mp3gain/README.Debian")
# (find-man "1 mp3gain")

normalize






# (find-fline "~/audios/")
cd ~/audios/
avconv -i 2013ago01-ict.3ga 2013ago01-ict.mp3


https://blog.scottlogic.com/2020/11/23/ffmpeg-webassembly.html
https://canvatechblog.com/a-journey-through-color-space-with-ffmpeg-3a129bfd9b05 ***

https://github.com/MaartenBaert/ssr#ffmpeg-vs-libav-confusion

https://news.ycombinator.com/item?id=33383023 Show HN: FFmpeg Command Visualizer and Editor (ffmpeg.guide)
https://ffmpeg.guide/
https://news.ycombinator.com/item?id=33771445 Guide to FFmpeg (img.ly) ***
https://www.paulox.net/2023/05/03/quickly_resize-a-video-with-ffmpeg-for-mastodon/
https://news.ycombinator.com/item?id=37199479 VidCutter: A program for lossless video cutting (github.com/ozmartian) - ffmpeg
https://news.ycombinator.com/item?id=34965535 FFmpeg 6.0 (ffmpeg.org)
https://news.ycombinator.com/item?id=34555465 A History of the FFmpeg Project (multimedia.cx)
https://xenodium.com/emacs-ffmpeg-and-macos-alias-commands/
https://news.ycombinator.com/item?id=31557809 Ffmpeg Buddy (evanhahn.github.io)
https://superuser.com/questions/624563/how-to-resize-a-video-to-make-it-smaller-with-ffmpeg
https://news.ycombinator.com/item?id=39938703 FFmpeg 7.0 (ffmpeg.org)
https://epiccoleman.com/posts/2023-03-19-ffmpeg-mp4-webm ***
https://github.com/mifi/lossless-cut 
https://news.ycombinator.com/item?id=40829494 LosslessCut: The Swiss army knife of lossless video/audio editing (github.com/mifi)
https://news.ycombinator.com/item?id=40892812 Ask HN: Where are the good resources for learning audio processing?
https://indieweb.social/@xenodium/112841493311260010 M-x speed-up-video-fragment
https://www.reddit.com/r/emacs/comments/1ew1fmm/experimental_transient_interface_for_barebones/

https://lav.io/notes/ffmpeg-explorer/ ***





#  Local Variables:
#  coding:               utf-8-unix
#  modes:                (fundamental-mode sh-mode)
#  End: