Notes on ffmpeg
- Transcode audio with metadata
- Encode/compress raw video and audio
- Screencast on Linux with PulseAudio
- Video to GIF
- Trim/cut video to video
- Misc
- Videos with wrong orientation in metadata
- Map video and audio streams into single output
- References
Transcode audio with metadata
ffmpeg
and quodlibet
/operon
Encode/compress raw video and audio
Compress raw video into Matroska container, see Digitizing Hi8 cassettes & Digitizing VHS cassettes.
Screencast on Linux with PulseAudio
Choose a PulseAudio source device
To perform capture and lossless compression with x264 and Vorbis in one go, run:
With microphone
Close pavucontrol
and run below to load loopback module
Open pavucontrol
again, and configure using below pictures as guide
Substitute below level to 70%
Substitute below level Built-in Audio Analog Stereo to 70%
Then repeat steps above.
Video to GIF
Manually extract portion of video into a video file adding extra stuff like effects, subtitles, merges with images, etc.
Resize video to desired size of GIF, using only one coordinate
If you get an error about audio encoding, just copy/reencode the same audio
File extension mp4
refers only to container, is not that relevant. Use
whatever the original video extension is.
Finally, convert to GIF
Online
- https://imgur.com/vidgif. Video must be hosted elsewhere. Creates both
video and GIF; to get GIF add
.gif
to the URL. - https://giphy.com/
- http://www.video2gif.org/about.html
- https://imgflip.com/
Trim/cut video to video
Trim/cut from minute 18:20 to 18:30. Try following commands in descending order of preference/priority.
Fast without re-encoding
About as fast as previous, no re-encoding
Slower, more accurate, with re-encoding
Slower, CPU-intensive, more accurate, with re-encoding
Short Python script
Misc
-
Use H.264 because of its good quality, size and compatibility.
-
Use MP4 if using audio compression, otherwise use Matroska.
-
When dealing with raw audio (PCM) specify the format with the
-f
option (for example). -
Don’t try to map audio channels without re-encoding (info).
Videos with wrong orientation in metadata
Sometimes when recording from a device like a cellphone or a tablet, the resulting video will play as if it was recorded in portrait mode
Below command fixes it without re-encoding.
Map video and audio streams into single output
Merge the video stream of normal_export.mkv
and audio stream of
normal_export_Audio_1.mkv
into a single container MKV
normal_export_final.mkv
.
References
- How to Install FFmpeg on Windows, Mac, Linux Ubuntu and Debian
- https://trac.ffmpeg.org/wiki/AudioChannelManipulation
- https://trac.ffmpeg.org/wiki/audio%20types
- https://wiki.archlinux.org/index.php/FFmpeg
- https://trac.ffmpeg.org/wiki/Encode/H.264
- https://trac.ffmpeg.org/wiki/Capture/Desktop
- https://ffmpeg.org/ffmpeg-devices.html
- http://wiki.oz9aec.net/index.php/High_quality_screen_capture_with_Ffmpeg
- https://askubuntu.com/questions/123798/how-to-hear-my-voice-in-speakers-with-a-mic
- http://blog.superuser.com/2012/02/24/ffmpeg-the-ultimate-video-and-audio-manipulation-tool/
- https://trac.ffmpeg.org/wiki