| 1 |
Always use `getResourcePath()` to get the appropriate path to these resources depending |
| 2 |
on the context (WPT, standalone, worker, etc.) |
| 3 |
|
| 4 |
|
| 5 |
The test video files were generated with by ffmpeg cmds below: |
| 6 |
``` |
| 7 |
// Generate four-colors-vp8-bt601.webm, mimeType: 'video/webm; codecs=vp8' |
| 8 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv four-colors-vp8-bt601.webm |
| 9 |
|
| 10 |
// Generate four-colors-h264-bt601.mp4, mimeType: 'video/mp4; codecs=avc1.4d400c' |
| 11 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libx264 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv four-colors-h264-bt601.mp4 |
| 12 |
|
| 13 |
// Generate four-colors-vp9-bt601.webm, mimeType: 'video/webm; codecs=vp9' |
| 14 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx-vp9 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv four-colors-vp9-bt601.webm |
| 15 |
|
| 16 |
// Generate four-colors-vp9-bt709.webm, mimeType: 'video/webm; codecs=vp9' |
| 17 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx-vp9 -pix_fmt yuv420p -frames 50 -colorspace bt709 -color_primaries bt709 -color_trc bt709 -color_range tv -vf scale=out_color_matrix=bt709:out_range=tv four-colors-vp9-bt709.webm |
| 18 |
|
| 19 |
// Generate four-colors-vp9-bt601.mp4, mimeType: 'video/mp4; codecs=vp9' |
| 20 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx-vp9 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv four-colors-vp9-bt601.mp4 |
| 21 |
``` |
| 22 |
|
| 23 |
Generate video files to test rotation behaviour. |
| 24 |
Use ffmepg to rotate video content x degrees in cw direction (by using `transpose`) and update transform matrix in metadata through `display_rotation` to x degrees to apply ccw direction rotation. |
| 25 |
|
| 26 |
H264 rotated video files are generated by ffmpeg cmds below: |
| 27 |
``` |
| 28 |
// Generate four-colors-h264-bt601-rotate-90.mp4, mimeType: 'video/mp4; codecs=avc1.4d400c' |
| 29 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libx264 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv -vf transpose=2 temp.mp4 |
| 30 |
ffmpeg -display_rotation 270 -i temp.mp4 -c copy four-colors-h264-bt601-rotate-90.mp4 |
| 31 |
rm temp.mp4 |
| 32 |
|
| 33 |
// Generate four-colors-h264-bt601-rotate-180.mp4, mimeType: 'video/mp4; codecs=avc1.4d400c' |
| 34 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libx264 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv -vf transpose=2,transpose=2 temp.mp4 |
| 35 |
ffmpeg -display_rotation 180 -i temp.mp4 -c copy four-colors-h264-bt601-rotate-180.mp4 |
| 36 |
rm temp.mp4 |
| 37 |
|
| 38 |
// Generate four-colors-h264-bt601-rotate-270.mp4, mimeType: 'video/mp4; codecs=avc1.4d400c' |
| 39 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libx264 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv -vf transpose=1 temp.mp4 |
| 40 |
ffmpeg -display_rotation 90 -i temp.mp4 -c copy four-colors-h264-bt601-rotate-270.mp4 |
| 41 |
rm temp.mp4 |
| 42 |
|
| 43 |
``` |
| 44 |
|
| 45 |
Vp9 rotated video files are generated by ffmpeg cmds below: |
| 46 |
``` |
| 47 |
// Generate four-colors-vp9-bt601-rotate-90.mp4, mimeType: 'video/mp4; codecs=vp9' |
| 48 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx-vp9 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv -vf transpose=2 temp.mp4 |
| 49 |
ffmpeg -display_rotation 270 -i temp.mp4 -c copy four-colors-vp9-bt601-rotate-90.mp4 |
| 50 |
rm temp.mp4 |
| 51 |
|
| 52 |
// Generate four-colors-vp9-bt601-rotate-180.mp4, mimeType: 'video/mp4; codecs=vp9' |
| 53 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx-vp9 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv -vf transpose=2,transpose=2 temp.mp4 |
| 54 |
ffmpeg -display_rotation 180 -i temp.mp4 -c copy four-colors-vp9-bt601-rotate-180.mp4 |
| 55 |
rm temp.mp4 |
| 56 |
|
| 57 |
// Generate four-colors-vp9-bt601-rotate-270.mp4, mimeType: 'video/mp4; codecs=vp9' |
| 58 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx-vp9 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv -vf transpose=1 temp.mp4 |
| 59 |
ffmpeg -display_rotation 90 -i temp.mp4 -c copy four-colors-vp9-bt601-rotate-270.mp4 |
| 60 |
rm temp.mp4 |
| 61 |
|
| 62 |
``` |
| 63 |
|
| 64 |
Generate video files to test flip behaviour. |
| 65 |
Use ffmpeg to flip video content. Using `display_hflip` to do horizontal flip and `display_vflip` to do vertical flip. |
| 66 |
|
| 67 |
H264 flip video files are generated by ffmpeg cmds below: |
| 68 |
``` |
| 69 |
// Generate four-colors-h264-bt601-hflip.mp4, mimeType: 'video/mp4; codecs=avc1.4d400c' |
| 70 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libx264 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv temp.mp4 |
| 71 |
ffmpeg -display_hflip -i temp.mp4 -c copy four-colors-h264-bt601-hflip.mp4 |
| 72 |
rm temp.mp4 |
| 73 |
|
| 74 |
// Generate four-colors-h264-bt601-vflip.mp4, mimeType: 'video/mp4; codecs=avc1.4d400c' |
| 75 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libx264 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv temp.mp4 |
| 76 |
ffmpeg -display_vflip -i temp.mp4 -c copy four-colors-h264-bt601-vflip.mp4 |
| 77 |
rm temp.mp4 |
| 78 |
|
| 79 |
``` |
| 80 |
|
| 81 |
Vp9 flip video files are generated by ffmpeg cmds below: |
| 82 |
``` |
| 83 |
// Generate four-colors-vp9-bt601-hflip.mp4, mimeType: 'video/mp4; codecs=vp09.00.10.08' |
| 84 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx-vp9 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv temp.mp4 |
| 85 |
ffmpeg -display_hflip -i temp.mp4 -c copy four-colors-vp9-bt601-hflip.mp4 |
| 86 |
rm temp.mp4 |
| 87 |
|
| 88 |
// Generate four-colors-vp9-bt601-vflip.mp4, mimeType: 'video/mp4; codecs=vp09.00.10.08' |
| 89 |
ffmpeg.exe -loop 1 -i .\four-colors.png -c:v libvpx-vp9 -pix_fmt yuv420p -frames 50 -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range tv temp.mp4 |
| 90 |
ffmpeg -display_vflip -i temp.mp4 -c copy four-colors-vp9-bt601-vflip.mp4 |
| 91 |
rm temp.mp4 |
| 92 |
|
| 93 |
``` |
| 94 |
|
| 95 |
The test jpg files were generated with by exiftool cmds and other image tools in below steps: |
| 96 |
``` |
| 97 |
// Generate four-colors.jpg with no orientation metadata |
| 98 |
Use a image tool (e.g. "Paint" app on Windows) to create four-colors.jpg from four-colors.png and check with exiftool to ensure no orientation metadata been set. |
| 99 |
|
| 100 |
// Generate jpg picture with 90 cw rotation metadata |
| 101 |
Use a image tool (e.g. "Paint" app on Windows) to create four-colors-hard-rotate-90-ccw.jpg and check with exiftool to ensure no orientation metadata been set. |
| 102 |
exiftool -Orientation#=6 four-colors-hard-rotate-90-ccw.jpg -o four-colors-rotate-90-cw.jpg |
| 103 |
rm four-colors-hard-rotate-90-ccw.jpg |
| 104 |
|
| 105 |
// Generate jpg picture with 180 cw rotation metadata |
| 106 |
Use a image tool (e.g. "Paint" app on Windows) to create four-colors-hard-rotate-180-ccw.jpg and check with exiftool to ensure no orientation metadata been set. |
| 107 |
exiftool -Orientation#=3 four-colors-hard-rotate-180-ccw.jpg -o four-colors-rotate-180-cw.jpg |
| 108 |
rm four-colors-hard-rotate-180-ccw.jpg |
| 109 |
|
| 110 |
// Generate jpg picture with 270 cw rotation metadata |
| 111 |
Use a image tool (e.g. "Paint" app on Windows) to create four-colors-hard-rotate-270-ccw.jpg and check with exiftool to ensure no orientation metadata been set. |
| 112 |
exiftool -Orientation#=8 four-colors-hard-rotate-270-ccw.jpg -o four-colors-rotate-270-cw.jpg |
| 113 |
rm four-colors-hard-rotate-270-ccw.jpg |
| 114 |
|
| 115 |
``` |