Converting video/audio using avconv
These examples show you how to convert videos using avconv.
The general usage of avconv is:
$avconv [global_options] [input options] -i [some_inputfile] [output_options] [output file].
Convert from raw x264 to quicktime mov:
./avconv -i test_input.264 -vcodec copy output.mov
Convert from raw x264 to flv (when you get an error with monotonically increasing dts):
./avconv -i test_input.264 -vcodec copy output.flv
Convert from flv to mov and specify bitrate:
./avconv -i test_input.flv -b 512k output.mov
Extract audio from movie:
./avconv -i test_input.mp4 -acodec copy -vn -y out.aac
Export only video from movie:
./avconv -i input.mov -an -vcodec copy out.mov
Combine audio and video file
./avconv -i video_input.mov -i audio_input.mp3 -c copy audio_and_video.mov
Create video from image sequence
./avconv -f image2 -i image-%03d.jpeg -b 65536k -r 24 out.mov
Create video from image sequence (really good quality)
./avconv -f image2 -i %04d.png -vcodec h264 -crf 1 -r 24 out.mov
Extract one second from a video
./avconv -ss 00:00:00 -i scanner.mov -t 00:00:01 -vcodec copy scanner_small.mov
Read raw RGB frames from tcp and convert them into a video
./avconv -v debug -f rawvideo -pix_fmt rgb24 -s 320x240 -i tcp://localhost:2233 -vcodec h264 result.mov
Add audio to a video file and make sure the shortest stream is used, also show some debug info
./avconv -v debug -i audio.wav -i video.mp4 -acodec libmp3lame -qscale 20 -shortest output.mov
Combining image sequences which are spread over multiple directories (on unices)
cat dir_a/*.jpg dir_b/*.jpg dir_c/*.jpg | ./avconv -f image2pipe -vcodec mjpeg -i - -r 25 -map 0 -map 1 out.mov
Combining image sequences which are spread over multiple directories (on windows, note the slashes)
type dir_a\\*.jpg dir_b\\*.jpg dir_c\\*.jpg | avconv.exe -f image2pipe -vcodec mjpeg -i - -r 25 -map 0 -map 1 out.mov
Combining image sequences which are spread over multiple directories and set a quality scale, use the shortest stream (audio of video)
cat dir_a/*.jpg dir_b/*.jpg dir_c/*.jpg ./avconv | ./avconv -f image2pipe -vcodec mjpeg -i - -i audio.mp3 -acodec libmp3lame -qscale 20 -shortest -r 25 -map 0 -map 1 out.mov
Exporting frames from a video; qscale is the quality, 1 = excellent, 31 = worst
./avconv -i intro.mov -vsync 1 -r 25 -an -y -qscale 1 out_%04d.jpg
Exporting frames from a video + resize output ; qscale is the quality, 1 = excellent, 31 = worst
./avconv -i intro.mov -vsync 1 -r 25 -an -y -qscale 1 -s 1280x720 out_%04d.jpg
You can write raw YUV frames into one container "yuv.raw" and then convert it into a video using:
./avconv -v debug -f rawvideo -pix_fmt yuv420p -s 320x240 -i raw.yuv -r 1 -vcodec h264 out.mov
Convert PCM audio, 2 channels, interleaved float 32 (le), rate 4800 to wav:
./avconv -f f32le -ac 2 -ar 48000 -i out.pcm out.wav
Speed up a movie:
./avconv -i out.mov -filter:v "setpts=0.5*PTS" out2.mov
Create a h264 based video that only contains IDR frames:
./avconv -i bbb.avi -an -vcodec x264 -g 1 -bsf h264_mp4toannexb out.h264
Convert a file which contains raw rgb24 frames into a yuv420p stream:
avconv -v debug -f rawvideo -pix_fmt rgb24 -s 1280x720 -i frames.raw -pix_fmt yuv420p frames.yuv
Convert a h264 stream into a mp4 file.
avconv -v debug -f h264 -i out.h264 -codec copy -y out.mp4
Convert a raw file with NV12 into a MP4 and set framerate to 60.
./avconv -v debug -r 60 -f rawvideo -pix_fmt nv12 -s 640x480 -i yuy2_generator_downloader.nv12 -r 60 -y yuy2_generator_downloader.mp4
Convert a h264 file to annex-b and disable b-frames:
./avconv -i sourcing2.mp4 -vcodec h264 -an -bsf h264_mp4toannexb -bf 0 data/sourcing2.h264
NAT Types
Building Cabinets
Compiling GStreamer from source on Windows
Debugging CMake Issues
Dual Boot Arch Linux and Windows 10
Mindset Updated Edition, Carol S. Dweck (Book Notes)
How to setup a self-hosted Unifi NVR with Arch Linux
Blender 2.8 How to use Transparent Textures
Compiling FFmpeg with X264 on Windows 10 using MSVC
Blender 2.8 OpenGL Buffer Exporter
Blender 2.8 Baking lightmaps
Blender 2.8 Tips and Tricks
Setting up a Bluetooth Headset on Arch Linux
Compiling x264 on Windows with MSVC
C/C++ Snippets
Reading Chunks from a Buffer
Handy Bash Commands
Building a zero copy parser
Kalman Filter
Saving pixel data using libpng
Compile Apache, PHP and MySQL on Mac 10.10
Fast Pixel Transfers with Pixel Buffer Objects
High Resolution Timer function in C/C++
Rendering text with Pango, Cairo and Freetype
Fast OpenGL blur shader
Spherical Environment Mapping with OpenGL
Using OpenSSL with memory BIOs
Attributeless Vertex Shader with OpenGL
Circular Image Selector
Decoding H264 and YUV420P playback
Fast Fourier Transform
OpenGL Rim Shader
Rendering The Depth Buffer
Delaunay Triangulation
RapidXML
Git Snippets
Basic Shading With OpenGL
Open Source Libraries For Creative Coding
Bouncing particle effect
OpenGL Instanced Rendering
Mapping a texture on a disc
Download HTML page using CURL
Height Field Simulation on GPU
OpenCV
Some notes on OpenGL
Math
Gists to remember
Reverse SSH
Working Set
Consumer + Producer model with libuv
Parsing binary data
C++ file operation snippets
Importance of blur with image gradients
Real-time oil painting with openGL
x264 encoder
Generative helix with openGL
Mini test with vector field
Protractor gesture recognizer
Hair simulation
Some glitch screenshots
Working on video installation
Generative meshes
Converting video/audio using avconv
Auto start terminal app on mac
Export blender object to simple file format