Skip to content

Instantly share code, notes, and snippets.

@jcburns
Last active April 10, 2019 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcburns/48a529cf1e130fe7802f7c13944ab6e4 to your computer and use it in GitHub Desktop.
Save jcburns/48a529cf1e130fe7802f7c13944ab6e4 to your computer and use it in GitHub Desktop.

encoding DV video (and others) from ffmpeg

ffmpeg -i /Users/jcburns/Movies/blurry\ motion\ thingie.mov -vf scale=720x480,setdar=4/3 -pix_fmt yuv411p -c:v dvvideo testblurry.mov

input comes first, then vf scale thing, including the dar, the display aspect ratio

you have to tell it -pix_fmt yuv411p because DV coming in as 422 (as it would in ProRes) will by default be encoded as DVCPRO50.

[dvvideo @ 0x7fd0ef026e00] Frame size: 720x480; pixel format: yuv411p, framerate: 30000/1001
[dvvideo @ 0x7fd0ef026e00] Frame size: 720x576; pixel format: yuv420p, framerate: 25/1
[dvvideo @ 0x7fd0ef026e00] Frame size: 720x576; pixel format: yuv411p, framerate: 25/1
[dvvideo @ 0x7fd0ef026e00] Frame size: 720x480; pixel format: yuv422p, framerate: 30000/1001
[dvvideo @ 0x7fd0ef026e00] Frame size: 720x576; pixel format: yuv422p, framerate: 25/1
[dvvideo @ 0x7fd0ef026e00] Frame size: 1280x1080; pixel format: yuv422p, framerate: 30000/1001
[dvvideo @ 0x7fd0ef026e00] Frame size: 1440x1080; pixel format: yuv422p, framerate: 25/1
[dvvideo @ 0x7fd0ef026e00] Frame size: 960x720; pixel format: yuv422p, framerate: 60000/1001
[dvvideo @ 0x7fd0ef026e00] Frame size: 960x720; pixel format: yuv422p, framerate: 50/1
[dvvideo @ 0x7fd0ef026e00] Frame size: 720x576; pixel format: yuv420p, framerate: 25/1
dvvideo (dvcp / 0x70637664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 29.97 fps, 30k tbn, 29.97 tbc

Video (NTSC DV)

ID						: 1
Format					: DV
Codec ID				: dvc
Duration				: 10 s 10 ms
Bit rate mode			: Constant
Bit rate				: 24.4 Mb/s
Encoded bit rate 		: 28.8 Mb/s
Width					: 720 pixels
Height					: 480 pixels
Display aspect ratio	: 4:3
Frame rate mode			: Constant
Frame rate				: 29.970 (30000/1001) FPS
Original frame rate		: 29.970 (29970/1000) FPS
Standard				: NTSC
Color space				: YUV
Chroma subsampling		: 4:1:1
Bit depth				: 8 bits
Scan type				: Progressive
Original scan type		: Interlaced
Original scan order		: Bottom Field First
Compression mode		: Lossy
Bits/(Pixel*Frame)		: 2.357
Stream size				: 29.1 MiB (85%)
Encoded stream size		: 34.3 MiB (100%)
Language				: English

Video (DVCPRO50)

ID						: 1
Format					: DV
Codec ID				: dv5n
Duration				: 10 s 10 ms
Bit rate mode			: Constant
Bit rate				: 24.4 Mb/s
Encoded bit rate		: 28.8 Mb/s
Width					: 720 pixels
Height					: 480 pixels
Display aspect ratio	: 4:3
Frame rate mode			: Constant
Frame rate				: 29.970 (30000/1001) FPS
Original frame rate		: 29.970 (29970/1000) FPS
Standard				: NTSC
Color space				: YUV
Chroma subsampling		: 4:2:2
Bit depth				: 8 bits
Scan type				: Progressive
Original scan type		: Interlaced
Original scan order		: Bottom Field First
Compression mode		: Lossy
Bits/(Pixel*Frame)		: 2.357
Stream size				: 29.1 MiB (42%)
Encoded stream size		: 68.7 MiB (100%)
Language				: English

ffmpeg -h encoder=dvvideo

Encoder dvvideo [DV (Digital Video)]:

General capabilities: threads intraonly Threading capabilities: frame and slice Supported pixel formats: yuv411p yuv422p yuv420p dvvideo encoder AVOptions: -quant_deadzone <int> E..V..... Quantizer dead zone (from 0 to 1024) (default 7)

Encoder prores [Apple ProRes]:

General capabilities: threads intraonly Threading capabilities: frame Supported pixel formats: yuv422p10le yuv444p10le yuva444p10le ProRes encoder AVOptions:* -vendor <string> E..V..... vendor ID (default "fmpg")

Encoder prores_aw (formerly named "prores_anatolyi") [Apple ProRes]:

General capabilities: threads intraonly Threading capabilities: frame Supported pixel formats:yuv422p10le yuv444p10le yuva444p10le ProResAw encoder AVOptions: -vendor <string> E..V..... vendor ID (default "fmpg")

Encoder prores_ks (formerly named "prores_kostya") [Apple ProRes (iCodec Pro)]:

General capabilities: threads intraonly Threading capabilities: frame and slice Supported pixel formats: yuv422p10le yuv444p10le yuva444p10le ProRes encoder AVOptions:

 -mbs_per_slice		<int>			E..V..... macroblocks per slice (from 1 to 8) (default 8)
 -profile			<int>			E..V..... (from -1 to 5) (default auto)
  auto								E..V.....
  proxy								E..V.....
  lt								E..V.....
  standard							E..V.....
  hq								E..V.....
  4444								E..V.....
  4444xq							E..V.....
 -vendor			<string>		E..V..... vendor ID (default "Lavc")
 -bits_per_mb		<int>			E..V..... desired bits per macroblock (from 0 to 8192) (default 0)
 -quant_mat			<int>			E..V..... quantiser matrix (from -1 to 6) (default auto)
  auto								E..V.....
  proxy								E..V.....
  lt								E..V.....
  standard							E..V.....
  hq								E..V.....
  default							E..V.....
 -alpha_bits		<int>			E..V..... bits for alpha plane (from 0 to 16) (default 16)

Apple ProRes variations

Format						: ProRes(Apple ProRes 4444 XQ)
Format version				: Version 1
Format profile				: 4444 XQ
Codec ID					: ap4x
Format						: ProRes(Apple ProRes 422 LT)
Format version				: Version 0
Format profile				: 422 LT
Codec ID					: apcs
Format						: ProRes(Apple ProRes 4444)
Format version				: Version 1
Format profile				: 4444
Codec ID					: ap4h
Format						: ProRes(Apple Prores 422 HQ)
Format version				: Version 0
Format profile				: 422 HQ
Codec ID					: apch

https://trac.ffmpeg.org/wiki/Encode/VFX

In our testing we've used the "prores" and the "prores_ks" encoders and found "prores_ks" to be the best encoder to use. It is the only one that supports the 4444 colorspace and although it may be slightly slower. The color quality of the videos produced by these two codecs was visually indistinguishable Because of the 4444 support we've decided to go with Kostya's version of prores.

There are 4 profiles that exist within Prores: Proxy, LT, SQ and HQ (and then optionally 4444). In ffmpeg these profiles are assigned numbers (0 is Proxy and 3 is HQ). See Apple's official Prores whitepaper for details on the codec and information associated with the profiles. For quick reference, the basic difference is the bitrates: (TODO). The other option that is used with prores is the -pix_fmt option. This is normally set to yuv422p10le or something like that, but if you want to use the 4444 prores you would set it to yuva444p10le. (A list of possible pixel formats can be invoked by running ffmpeg -pix_fmts. Note that not all of these formats are actually supported with prores).

maybe make a photoJPEG movie

ffmpeg -i /Users/jcburns/Movies/verni.mov -c:v mjpeg -qscale:v 1 -vendor ap10 -pix_fmt yuvj422p testverni.mov

Just fix displayed aspect ratio

ffmpeg -i /Users/jcburns/Movies/atlanta1980_wt_01.mov -aspect 4:3 -c copy atlanta1980_wt_01.mov

convert slide sequence to mp4

ffmpeg -i images%05d.jpg -pix_fmt yuv420p -aspect 4:3 allslides.mp4

mute first 4 secs of audio, preserve video

ffmpeg -i /Volumes/3TB_videolandia/cnn\ headline\ news\ cnnhn_1989/cnnhn_hollywood_minute.mov -aspect 4:3 -vcodec copy -af "volume=enable='between(t,0,4)':volume=0" cnnhn_hollywood_minute.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment