FFmpeg Commands That Have Worked for Me

Record Sound only *.wav or *.mp3

ffmpeg -f alsa -i plughw:CARD=H3100,DEV=0 -acodec libmp3lame -t 20 output.wav ffmpeg -f alsa -i plughw:CARD=H3100,DEV=0 -acodec libmp3lame -t 20 output.MP3 BOTH worked fine for me.

Record video and sound This is from a HP3100 USB camera and microphone.

This works pretty good I think. I did not check the sync : ffmpeg -f alsa -i pulse -f x11grab -r 17 -s 1360x760 -i :0.0 -acodec pcm_s16le catchit.mkv ffmpeg -thread_queue_size 512 -f alsa -i pulse -f x11grab -r 17 -s 1280x720 -i :0.0 -acodec pcm_s16le 0001.mkv ffmpeg -thread_queue_size 768 -f alsa -i pulse -f x11grab -r 17 -s 1280x720 -i :0.0 -acodec pcm_s16le 0001.mkv

I WILL USE THIS SREEN RECORDER

 - NO ERRORS GREAT RECORDING - Works well with Gimp and Blender ;
works with HP3100 microphone or with headsets:
ffmpeg -thread_queue_size 768 -f alsa -i pulse -f x11grab -r 17 -s 1360x760 -i :0.0 -preset ultrafast -acodec pcm_s16le 0003.mkv 

experimental:
ffmpeg -f alsa -r 16000 -i hw:2,0 -f video4linux2 -s 800x600 -i /dev/video0 -r 30 -f avi -vcodec mpeg4 -vtag xvid -qscale 0 -acodec libmp3lame -ab 96k output.avi

ffmpeg -f alsa -r 16000 -i plughw:CARD=H3100,DEV=0 -f video4linux2 -s 800x600 -i /dev/video0 -r 30 -f avi -vcodec mpeg4 -vtag xvid -qscale 0 -acodec libmp3lame -ab 96k output.mp4

ffmpeg -f alsa -i plughw:CARD=H3100,DEV=0 -acodec libmp3lame -ab 96k -s hd720 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast desktop.mkv

Ffmpeg may be used with no options

The i- following ffmpeg proceeds the file name. The simple command below uses same size and the frame rate defaults to 25 ( -framerate 25 ).

ffmpeg -i infile.avi youroutput.mp4

If you wish to keep the frame sizes and frame rate intact use the -strict option. it results in a high quality video if possible.
ffmpeg -i input.avi -strict -2 output.mp4

ffmpeg -i input.mkv -codec copy output.mp4

Good Screen Capture - NO errors

ffmpeg -f x11grab -r 17 -s 1360x760 -i :0.0 -vcodec libx264 -preset ultrafast test001.mp4 Good HAS ERRORS: ffmpeg -video_size 1360x760 -framerate 25 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast another-capture.mkv Stabilize a video: ffmpeg -i input.mov -vf deshake output.mov Screen Capture using ffmpeg works with headset: shows warnings but works fine ffmpeg -framerate 25 -video_size 1360x760 -f x11grab -i :0.0 -f alsa -ac 2 -i pulse -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv works with warnings: shows even more warnings but works fine ffmpeg -framerate 17 -s hd720 -f x11grab -i :0.0 -f alsa -ac 2 -i pulse -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le motest.mkv

works with my hp3100 WebCam

ffmpeg -thread_queue_size 512 -f alsa -ac 1 -ar 48000 -i plughw:CARD=H3100,DEV=0 -s 1366x768 -f x11grab -i :0 -r 30 -vcodec libx264 testit.mkv

the HP3100 Webcam option

-i plughw:CARD=H3100,DEV=0 GOOD ( no audio ) !! Lossless recording ffmpeg -video_size 1360x750 -framerate 17 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast desktop2.mkv -qp 0 tells x264 to encode in lossless mode and the -preset ultrafast instructs 'do it fast' fast. The encoder should be fast enough on most modern hardware to record without any framedrop, and even leave enough CPU headroom for other applications. If you're going to archive the recording or are concerned about file size, re-encode it losslessly again but with a slower preset. Note that since the initial recording was lossless, and the re-encode is lossless too, no quality loss is introduced in this process in any way. ffmpeg -i desktop.mkv -c:v libx264 -qp 0 -preset veryslow smaller_size_desktop.mkv See Encode/H.264 for more info and examples. Linux: Use the x11grab device: ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output.mp4 This will grab the image from desktop, starting with the upper-left corner at (x=100, y=200) with the width and height of 1024x768. If you need audio too you can use ALSA (see Capture/ALSA for more info): ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i hw:0 output.mkv Or the pulse input device: ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f pulse -ac 2 -i default output.mkv

Adding Subtitles

Both worked fine - mkvmerge and ffmpeg mkvmerge -o output.mkv sharpen.mkv space.srt ffmpeg -i infile.mp4 -f srt -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4

To View the video information on a video called 'SpaceSubtitle_ffmpeg.mp4':

ffprobe -v error -show_format -show_streams SpaceSubtitle_ffmpeg.mp4
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High 4:4:4 Predictive
codec_type=video
codec_time_base=1/34
codec_tag_string=avc1
codec_tag=0x31637661
width=1000
height=1000
coded_width=1008
coded_height=1008
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=1:1
pix_fmt=yuv444p
level=32
color_range=N/A
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
timecode=N/A
refs=4
is_avc=1
nal_length_size=4
id=N/A
r_frame_rate=17/1
avg_frame_rate=2240000/131757
time_base=1/16000
start_pts=0
start_time=0.000000
duration_ts=263514
duration=16.469625
bit_rate=2769392
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=280
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=VideoHandler
[/STREAM]
[STREAM]
index=1
codec_name=mov_text
codec_long_name=3GPP Timed Text subtitle
profile=unknown
codec_type=subtitle
codec_time_base=1/1000
codec_tag_string=tx3g
codec_tag=0x67337874
width=N/A
height=N/A
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=16470

----- end of response ---

Another File information command

The command below command is no designed to be a file information command, however it works as one. As you see it provides some erroneous information and concludes with an error "At least one output file must be specified". Ffprobe is the desired means of acquiring information.


jack@jack-desktop:~/blender$ ffmpeg -i SpaceSubtitle_ffmpeg.mp4ffmpeg version 2.7.6-0ubuntu0.15.10.1 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
  configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SpaceSubtitle_ffmpeg.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.36.100
  Duration: 00:00:16.47, start: 0.000000, bitrate: 2772 kb/s
    Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1000x1000 [SAR 1:1 DAR 1:1], 2769 kb/s, 17 fps, 17 tbr, 16k tbn, 34 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
    Metadata:
      handler_name    : SubtitleHandler
At least one output file must be specified

EXPERIMENT To show streaming video in a port. ffmpeg -i /dev/video0 -listen 1 -f matroska -c:v libx264 -preset fast -tune zerolatency http://:8080 ffplay http://localhost:8080/ See the scale and unsharp filters in ffmpeg: ffmpeg -i input -filter:v "scale=1280:-1,unsharp=5:5:1.0:5:5:0.0" output The -1 in the scale filter tells ffmpeg to automatically choose the correct height to preserve aspect ratio. You can change the scaler with the -sws_flags option, such as -sws_flags lanczos. For upsampling lanczos is worth trying. Default is bicubic. See the full list at ffmpeg -h full. The results of: ffmpeg -i infile.avi youroutput.mp4 ffmpeg lists each frame as it converts it. I am showing only the last 100 frames. frame= 5410 fps= 15 q=29.0 size= 57761kB time=00:03:00.95 bitrate=2614.9kbits/ frame= 5419 fps= 15 q=29.0 size= 57837kB time=00:03:00.95 bitrate=2618.4kbits/ frame= 5428 fps= 15 q=29.0 size= 57912kB time=00:03:00.95 bitrate=2621.8kbits/ frame= 5436 fps= 15 q=29.0 size= 57983kB time=00:03:01.95 bitrate=2610.6kbits/ frame= 5445 fps= 15 q=29.0 size= 58047kB time=00:03:01.95 bitrate=2613.5kbits/ frame= 5453 fps= 15 q=29.0 size= 58147kB time=00:03:01.95 bitrate=2617.9kbits/ frame= 5459 fps= 15 q=29.0 size= 58242kB time=00:03:01.95 bitrate=2622.2kbits/ frame= 5467 fps= 15 q=29.0 size= 58342kB time=00:03:02.95 bitrate=2612.4kbits/ frame= 5476 fps= 15 q=29.0 size= 58423kB time=00:03:02.95 bitrate=2616.0kbits/ frame= 5485 fps= 15 q=29.0 size= 58497kB time=00:03:02.95 bitrate=2619.4kbits/ frame= 5493 fps= 15 q=29.0 size= 58565kB time=00:03:03.94 bitrate=2608.1kbits/ frame= 5501 fps= 15 q=29.0 size= 58637kB time=00:03:03.94 bitrate=2611.3kbits/ frame= 5509 fps= 15 q=29.0 size= 58706kB time=00:03:03.94 bitrate=2614.4kbits/ frame= 5515 fps= 15 q=29.0 size= 58766kB time=00:03:03.94 bitrate=2617.1kbits/ frame= 5520 fps= 15 q=-1.0 Lsize= 59421kB time=00:03:04.01 bitrate=2645.3kbits /s speed=0.492x video:56347kB audio:2878kB subtitle:0kB other streams:0kB global headers:0kB mux ing overhead: 0.331550% [libx264 @ 00000000005397c0] frame I:23 Avg QP:21.33 size: 66958 [libx264 @ 00000000005397c0] frame P:1390 Avg QP:24.19 size: 22546 [libx264 @ 00000000005397c0] frame B:4107 Avg QP:27.28 size: 6043 [libx264 @ 00000000005397c0] consecutive B-frames: 0.7% 0.2% 0.3% 98.8% [libx264 @ 00000000005397c0] mb I I16..4: 6.2% 91.2% 2.6% [libx264 @ 00000000005397c0] mb P I16..4: 2.9% 12.3% 0.3% P16..4: 57.7% 14.0 % 8.1% 0.0% 0.0% skip: 4.7% [libx264 @ 00000000005397c0] mb B I16..4: 0.3% 1.5% 0.0% B16..8: 33.6% 3.9 % 0.7% direct: 4.5% skip:55.3% L0:48.2% L1:45.6% BI: 6.2% [libx264 @ 00000000005397c0] 8x8 transform intra:80.5% inter:85.6% [libx264 @ 00000000005397c0] coded y,uvDC,uvAC intra: 65.8% 92.4% 23.0% inter: 1 4.7% 37.0% 1.2% [libx264 @ 00000000005397c0] i16 v,h,dc,p: 12% 15% 4% 69% [libx264 @ 00000000005397c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 18% 23% 4% 7% 8% 7% 6% 7% [libx264 @ 00000000005397c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 19% 13% 5% 12% 10% 9% 5% 4% [libx264 @ 00000000005397c0] i8c dc,h,v,p: 49% 14% 27% 9% [libx264 @ 00000000005397c0] Weighted P-Frames: Y:3.0% UV:1.4% [libx264 @ 00000000005397c0] ref P L0: 35.0% 13.2% 34.3% 17.3% 0.2% [libx264 @ 00000000005397c0] ref B L0: 84.1% 10.5% 5.4% [libx264 @ 00000000005397c0] ref B L1: 95.7% 4.3% [libx264 @ 00000000005397c0] kb/s:2508.66 [aac @ 00000000005b9f80] Qavg: 943.549 ~Desktop$:/DCIM/Ffugi
References: https://ffmpeg.org/ https://wiki.archlinux.org/index.php/FFmpeg