Convert Video from Different Formats
Using OBS to Convert MKV to MP4
Install ffmpeg
You need to have ffmpeg
installed.
download at
Convert video file using ffmpeg
mov to mp4
ffmpeg -i x.mov x.mp4
webm to MP4
ffmpeg -i x.webm x.mp4
Clip a Video
ffmpeg -ss 00:10:05 -i input.mp4 -to 00:13:50 -c copy output.mp4
-ss time_off
- Set the start time offset
-to time_stop
- Record or transcode stop time
Find Out What's Inside a Video Container
mp4
,mkv
etc are Video and audio container formats.- They package together video file, audio files, and other files, of various formats into 1 file.
To find out what's inside, use ffprobe
, e.g.
ffprobe file.mkv
Example output:
~/web/xahmusic_org/music/i $ ffprobe xx.mkv ffprobe version 3.4 Copyright (c) 2007-2017 the FFmpeg developers built with Apple LLVM version 9.0.0 (clang-900.0.37) configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 Input #0, matroska,webm, from 'xx.mkv': Metadata: COMPATIBLE_BRANDS: iso6avc1mp41 MAJOR_BRAND : dash MINOR_VERSION : 0 ENCODER : Lavf57.83.100 Duration: 00:05:04.90, start: 0.000000, bitrate: 1329 kb/s Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default) Metadata: HANDLER_NAME : VideoHandler DURATION : 00:05:04.871000000 Stream #0:1(eng): Audio: vorbis, 44100 Hz, stereo, fltp (default) Metadata: DURATION : 00:05:04.903000000

Put a Opus Audio into a .Webm Container
ffmpeg -i x.opus -c:a copy x.webm
Add Opus Audio into Existing Webm
ffmpeg -i y.webm -i x.opus -c:v copy -c:a copy x.webm
Extract Audio from Video
extract audio file inside file x.mp4 and name it x.m4a
ffmpeg -i x.mp4 -vn -acodec copy x.m4a
ffmpeg -f mp4 -i x.mp4 -vn -c:a copy x.m4a
or
ffmpeg -f mp4 -i x.mp4 -map 0:1 -c:a copy x.m4a
-map 0:1
means stream number 1 from file number 0, which would usually be the audio track (edit as necessary).- specifying a map at all disables the default map which would be to copy every stream, so you get only the audio, not both.
-c:a copy
means just copy it, no re-encoding.- You may also want to specify a
-f
for the output to choose a container fomat; I am not sure what it will use by default, probably the same as the input.
2018-11-26
thanks to
harvhat
https://noagendasocial.com/@harvhat
and
matthew skala
https://mstdn.io/web/accounts/18568
Syntax of ffmpeg
The general syntax of ffmpeg is:
ffmpeg options infile_options -i infileName outfile_options outfileName
-f fmt
- force format fmt