https://support.google.com/youtube/answer/1722171?hl=en
This can be resolved by compiling ffmpeg in a terminal like this:Recommended bitrates, codecs, and resolutions, and more
Container: .mp4
Audio Codec: AAC-LC
Channels: Stereo or Stereo + 5.1
Sample rate 96khz or 48 khz
Video Codec: H.264
Progressive scan (no interlacing)
High Profile
2 consecutive B frames
Closed GOP. GOP of half the frame rate.
CABAC
Variable bitrate. No bitrate limit required
Color Space: 4.2.0
Frame rates
Content at 1080i 60, should be deinterlaced, going from 60 interlaced fields per second to 30 progressive frames per second before uploading.
Best AAC-LC encoder: http://trac.ffmpeg.org/wiki/AACEncodingGuide
libfdk_aac
Fraunhofer FDK AAC codec library. This is currently the highest-quality AAC encoder available with ffmpeg. Requires ffmpeg to be configured with --enable-libfdk_aac (and additionally--enable-nonfree if you're also using --enable-gpl). But beware, it defaults to a low-pass filter of around 14kHz. If you want to preserve higher frequencies, use -cutoff 18000. Adjust the number to the upper frequency limit you prefer.
Which encoder should I use? What provides the best quality?
For AAC-LC the likely answer is: libfdk_aac > libfaac > Native FFmpeg AAC encoder (aac) > libvo_aacenc.
libfdk_aac has been designated as "non-free", and you cannot download a pre-built ffmpeg that supports it.
Update repositories:
Code: Select all
sudo apt-get update
Code: Select all
mkdir ~/sourcefiles
Code: Select all
sudo apt-get remove ffmpeg
Code: Select all
sudo apt-get -y install autoconf automake build-essential git libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev
1 YASM:
Code: Select all
sudo apt-get install yasm
Code: Select all
sudo apt-get install libmp3lame-dev
Code: Select all
sudo apt-get install libvpx-dev
Code: Select all
cd ~/sourcefiles
git clone --depth 1 git://git.videolan.org/x264.git
cd x264
./configure --prefix="$HOME/ffmpeg_build" --bindir="/usr/local/bin" --enable-static
#./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static
make
sudo make install
make distclean
Code: Select all
cd ~/sourcefiles
wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz
tar xzvf opus-1.1.tar.gz
cd opus-1.1
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
sudo make install
make distclean
Code: Select all
cd ~/sourcefiles
git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
sudo make install
make distclean
Code: Select all
cd ~/sourcefiles
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="/usr/local/bin" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
make
sudo make install
make distclean
To see current version and compiled libraries:
Code: Select all
ffmpeg
Code: Select all
Ffmpeg -codecs
Code: Select all
ffmpeg -codecs | grep fdk
ffmpeg -codecs | grep 264
If you have some picture.jpg (or any format ffmpeg understands) you can simply convert it to a png with the maximum youtube size like this:
Code: Select all
ffmpeg -y -i picture.jpg -s 1920x1080 picture.png
Now you can create a video.mp4 file, that you can upload to youtube, like this:-y autoanswers Yes, overwrite file when asked
-i picture.jpg is the Input, picture, with format .jpg, but could be any format like .gif, .bmp, .png etc
-s 1920x1080 output size
picture.png is the output, written to a .png file in this case.
Code: Select all
ffmpeg -y -loop 1 -i picture.png -i audio.wav -c:a libfdk_aac -cutoff 20000 -vf fps=30 -pix_fmt yuv420p -aspect 16:9 -c:v libx264 -shortest video.mp4
Loop over a bunch of pictures:-y: overwrite? Yes.
-loop 1: loop = true for next input (the picture)
-i picture.png: input picture.png
-i audio.wav: input audio.wav
-c:a libfdk_aac: Codec for Audio uses Fraunhofer codec
-cutoff 20000: Fraunhofer cutoff value valid range is 173 - 20000, defaults to 14000 when not set
-vf fps=30: video format: frames per second to 30
-pix_fmt yuv420p: most widely recognized pixel color format
-aspect 16:9 :Set correct aspect ratio (default 4:3 gives black bands on sides)
-c:v libx264: Codec for Video uses libx264 (youtube best quality)
-shortest: stop the video when the first stream runs out (which is the audio, we loop the picture endlessly)
video.mp4: write output to video.mp4
Convert all pictures you want to use to fragments of video. -t 5.00 is the number of seconds. For example like this:
Code: Select all
ffmpeg -y -loop 1 -i picture000.png -s 1920x1080 -vf fps=30 -pix_fmt yuv420p -aspect 16:9 -c:v libx264 -t 1.00 picture000.mp4
ffmpeg -y -loop 1 -i picture001.jpg -s 1920x1080 -vf fps=30 -pix_fmt yuv420p -aspect 16:9 -c:v libx264 -t 15.00 picture001.mp4
ffmpeg -y -loop 1 -i picture002.gif -s 1920x1080 -vf fps=30 -pix_fmt yuv420p -aspect 16:9 -c:v libx264 -t 25.00 picture002.mp4
ffmpeg -y -loop 1 -i picture003.bmp -s 1920x1080 -vf fps=30 -pix_fmt yuv420p -aspect 16:9 -c:v libx264 -t 5.00 picture003.mp4
Code: Select all
file 'picture000.mp4'
file 'picture001.mp4'
file 'picture002.mp4'
file 'picture001.mp4'
file 'picture002.mp4'
file 'picture003.mp4'
Code: Select all
ffmpeg -y -f concat -i mylist.txt -vf fps=30 -pix_fmt yuv420p -aspect 16:9 -c:v libx264 pictures.mp4
Code: Select all
ffmpeg -y -i pictures.mp4 -i audio.wav -c:a libfdk_aac -cutoff 20000 -vf fps=30 -pix_fmt yuv420p -aspect 16:9 -c:v libx264 -shortest video.mp4
You can also download videos from youtube.
Code: Select all
sudo apt-get install youtube-dl
Code: Select all
http://www.youtube.com/watch?v=jbQlsV0sB5Y
yout(tab) (ctrl-shift-insert) (enter):
Which will work out as something like:
Code: Select all
youtube-dl http://www.youtube.com/watch?v=jbQlsV0sB5Y
It will download the video from youtube to your /home/YOURNAME/ folder. (Note: Some videos will fail to download due to copyright restrictions I guess, leading to failure by 'secret keys missing for the file')
You can inspect information about the video file like duration, screensize, codec used etc:
Code: Select all
ffmpeg -i video.mp4
Code: Select all
ffmpeg -y -i video.flv -c:a libfdk_aac -cutoff 20000 audio.aac
ffmpeg -y -i video.flv -c:a libmp3lame audio.mp3
ffmpeg -y -i video.mp4 -c:a libfdk_aac -cutoff 20000 audio.aac
ffmpeg -y -i video.mp4 -c:a libmp3lame audio.mp3
save to /home/YOURNAME/extractaudio.py:
Code: Select all
from subprocess import call
from os import listdir
from os.path import isfile, join
from sys import argv
#cutoff any frequencies above (cutoff valid range is 173 - 20000, default=14000) in aac:
aaccutoff="20000"
#you should set mypath to YOUR home folder
mypath="/home/bas"
def convert(shortnamein, codec):
listfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
listfiles2 = sorted(listfiles)
for f1 in listfiles2:
if f1[-4:].lower()==".mp4" or f1[-4:].lower()==".flv":
shortname=f1[:-4]+"."+shortnamein
if shortnamein=='aac':
call(["sudo", "ffmpeg", "-y", "-i", f1, "-c:a", codec, "-cutoff", aaccutoff, shortname])
elif shortnamein=='mp3':
call(["sudo", "ffmpeg", "-y", "-i", f1, "-c:a", codec, shortname])
if len(argv)==2 and argv[1].lower()=='mp3':
convert("mp3", "libmp3lame")
elif len(argv)==2 and argv[1].lower()=='aac':
convert("aac", "libfdk_aac")
else:
print 'Extracts audio from mp4/flv to lame-mp3 or Fraunhofer-aac'
print
print 'For MP3 use:'
print 'python extractaudio.py mp3'
print 'Note: perhaps you need mp3 lame encoder first, to install do'
print 'sudo apt-get install lame libavcodec-extra-53'
print
print 'for AAC use:'
print 'python extractaudio.py aac'
print 'Note: perhaps you need to compile ffmpeg with Fraunhofer'
print 'aac-library (aka libfdk_aac) support first'
Code: Select all
python extractaudio.py
Grab test video (size 1920x1080) from x11 (the screen)
Code: Select all
ffmpeg -f x11grab -r 30 -s 1920x1080 -i :0.0 /tmp/x11grab.mp4
record audio:
For pulseaudio (on top of alsa):
Open pavucontrol, and include 'monitor'
Input devices: all input devices
For JACK: in patchage or qjcackctl->connections, connect all sound going to 'system' (like PulseAudio JACK Sink and/or any jack applications you have in front of system) to 'PulseAudio JACK Source'.
Record pure wavefiles from speakers:
Code: Select all
ffmpeg -f alsa -ac 2 -i pulse /tmp/rawsound.wav
Code: Select all
ffmpeg -f alsa -ac 2 -i pulse -c:a libmp3lame -ar 48000 /tmp/mp3sound.mp3
Code: Select all
ffmpeg -f alsa -ac 2 -i pulse -c:a libfdk_aac /tmp/aacsound.aac
Code: Select all
ffmpeg -f alsa -ac 2 -i pulse -c:a libfdk_aac -f x11grab -r 30 -s 1920x1080 -i :0.0 /tmp/videowithaacsound.mp4
Code: Select all
ffmpeg -y -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1920x1080 -i :0.0 /tmp/screencast.mkv
Now we can edit the mkv, cut out failures, add noise filter, text or effects etc. When we are happy with the result, compress it for upload to youtube:
Code: Select all
ffmpeg -y -i /tmp/screencast.mkv -c:a libfdk_aac -cutoff 20000 -vf fps=30 -pix_fmt yuv420p -c:v libx264 /tmp/screencast.mp4