Skip to content

Commit

Permalink
Faststart (#68)
Browse files Browse the repository at this point in the history
* Adding the faststart flag.

Signed-off-by: [email protected] <[email protected]>

* Fixes for the doc tests.

Signed-off-by: [email protected] <[email protected]>

---------

Signed-off-by: [email protected] <[email protected]>
Co-authored-by: [email protected] <[email protected]>
  • Loading branch information
richardssam and SamRichardsDisney authored Nov 18, 2023
1 parent fbd224d commit ecc81aa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
3 changes: 1 addition & 2 deletions EncodeDNXHD.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ There really are not any significant flags to be used, changing bit-rate has no
<!---
name: test_dnxhd_rgb
sources:
- sourceimages/chip-chart-1080-16bit-noicc.png.yml
- sourceimages/smptehdbars_10.dpx.yml
comparisontest:
- testtype: idiff
compare_image: ../sourceimages/chip-chart-1080-16bit-noicc-yuv422p10le.png
- testtype: assertresults
tests:
- assert: less
Expand Down
5 changes: 3 additions & 2 deletions EncodeHevc.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ comparisontest:
ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -frames:v 200 -c:v libx265 \
-pix_fmt yuv420p10le -crf 22 -preset slow -sws_flags spline+accurate_rnd+full_chroma_int \
-vf "scale=in_range=full:in_color_matrix=bt709:out_range=tv:out_color_matrix=bt709" \
-color_range 1 -colorspace 1 -color_primaries 1 -color_trc 2 -y outputfile.mp4
-color_range 1 -colorspace 1 -color_primaries 1 -color_trc 2 \
-movflags faststart -y outputfile.mp4
```


Expand All @@ -62,7 +63,7 @@ ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -frames:v 200 -c:v libx265 \
| -x265-params lossless=1 | Does lossless encoding, -crf 0 is not required |
| -tag:v hvc1 | To make it "Apple "Industry standard" compliant |
| -profile main | Profile can be one of main or main10 or main12 |

**-movflags faststart | This re-organises the mp4 file, so that it doesnt have to read the whole file to start playback, useful for streaming. It can add a second or so to do this, since it does require re-writing the file. |
## libx265 crf values

To help pick appropriate values with the CRF flag, we have run the [Test Framework](enctests/README.html) through some of the [reference media](enctests/sources/enc_sources/README.html).
Expand Down
8 changes: 4 additions & 4 deletions EncodeProres.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Example encode would look like:
<!---
name: test_proresks
sources:
- sourceimages/chip-chart-1080-16bit-noicc.png.yml
- sourceimages/smptehdbars_10.dpx.yml
comparisontest:
- testtype: idiff
compare_image: ../sourceimages/chip-chart-1080-16bit-noicc-yuv422p10le.png
compare_image: ../sourceimages/smptehdbars_10_yuv422p10le.png
extracttemplate: "ffmpeg -y -i {newfile} -compression_level 10 -pred mixed -pix_fmt rgb48be -frames:v 1 -vf scale=in_color_matrix=bt709:out_color_matrix=bt709 -sws_flags area+accurate_rnd+full_chroma_int {newpngfile}"
- testtype: assertresults
tests:
Expand Down Expand Up @@ -108,10 +108,10 @@ If you are on a OSX M1 machine and are using ffmpeg 5.0 or higher, you can use t
<!---
name: test_prores_videotoolbox
sources:
- sourceimages/chip-chart-1080-16bit-noicc.png.yml
- sourceimages/smptehdbars_10.dpx.yml
comparisontest:
- testtype: idiff
compare_image: ../sourceimages/chip-chart-1080-16bit-noicc-yuv422p10le.png
compare_image: ../sourceimages/smptehdbars_10_yuv422p10le.png
extracttemplate: "ffmpeg -y -i {newfile} -compression_level 10 -pred mixed -pix_fmt rgb48be -frames:v 1 -vf scale=in_color_matrix=bt709:out_color_matrix=bt709 -sws_flags spline+accurate_rnd+full_chroma_int {newpngfile}"
- testtype: assertresults
tests:
Expand Down
4 changes: 3 additions & 1 deletion Encodeh264.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ ffmpeg -r 24 -start_number 100 -i inputfile.%04d.png -frames:v 200 -c:v libx264
-pix_fmt yuv420p10le -crf 18 -preset slow \
-sws_flags spline+accurate_rnd+full_chroma_int \
-vf "scale=in_range=full:in_color_matrix=bt709:out_range=tv:out_color_matrix=bt709" \
-color_range 1 -colorspace 1 -color_primaries 1 -color_trc 2 -y outputfile.mp4
-color_range 1 -colorspace 1 -color_primaries 1 -color_trc 2 \
-movflags faststart -y outputfile.mp4
```


Expand All @@ -54,6 +55,7 @@ ffmpeg -r 24 -start_number 100 -i inputfile.%04d.png -frames:v 200 -c:v libx264
| **-preset slow** | [https://trac.ffmpeg.org/wiki/Encode/H.264#FAQ](https://trac.ffmpeg.org/wiki/Encode/H.264#FAQ) |
| **-qscale:v 9** | Generic quality scale flag: [https://www.ffmpeg.org/ffmpeg.html#toc-Main-options](https://www.ffmpeg.org/ffmpeg.html#toc-Main-options) - TODO experiment with this. |
| **-tune film** | See below. |
**-movflags faststart | This re-organises the mp4 file, so that it doesnt have to read the whole file to start playback, useful for streaming. It can add a second or so to do this, since it does require re-writing the file. |

### Tune Parameter

Expand Down
11 changes: 7 additions & 4 deletions Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ If you are encoding from an [image sequence](FfmpegInputs.html) (e.g. imagefile.
<!---
name: test_quickstart
sources:
- sourceimages/chip-chart-1080-noicc.png.yml
- sourceimages/chip-chart-1080-16bit-noicc.png.yml
comparisontest:
- testtype: idiff
compare_image: ../sourceimages/chip-chart-1080-16bit-noicc-yuv420p.png
- testtype: assertresults
tests:
- assert: less
Expand All @@ -31,7 +32,7 @@ ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -sws_flags area+accurate_rnd+
-vf "scale=in_color_matrix=bt709:out_color_matrix=bt709" \
-frames:v 100 -c:v libx264 -preset slower \
-color_range tv -colorspace bt709 -color_primaries bt709 -color_trc iec61966-2-1 \
outputfile.mp4
-movflags faststart outputfile.mp4
```

| --- | --- |
Expand All @@ -46,6 +47,7 @@ ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -sws_flags area+accurate_rnd+
**-colorspace bt709** | mp4 metadata - specifying bt709 yuv color pixel format
**-color_primaries bt709** | mp4 metadata - bt709 color gamut primaries
**-color_trc iec61966-2-1** | mp4 metadata color transfer = iec61966-2-1 = sRGB - See tests [here](WebColorPreservation.html). In some cases, you may also want -color_trc bt709 |
**-movflags faststart | This re-organises the mp4 file, so that it doesnt have to read the whole file to start playback, useful for streaming. It can add a second or so to do this, since it does require re-writing the file. |

**-vf "scale=in_color_matrix=bt709:out_color_matrix=bt709"** means use the sw-scale filter, setting:

Expand All @@ -70,9 +72,10 @@ Unlike h264 and DnXHD, Prores is a reverse-engineered codec. However, in many ca
<!---
name: test_proresquickstart
sources:
- sourceimages/chip-chart-1080-noicc.png.yml
- sourceimages/smptehdbars_10.dpx.yml
comparisontest:
- testtype: idiff
compare_image: ../sourceimages/smptehdbars_10_yuv422p10le.png
- testtype: assertresults
tests:
- assert: less
Expand Down Expand Up @@ -103,7 +106,7 @@ As above, but using 4444 (i.e. a color value for each pixel + an alpha)
<!---
name: test_prores444
sources:
- sourceimages/chip-chart-1080-noicc.png.yml
- sourceimages/smptehdbars_10.dpx.yml
comparisontest:
- testtype: idiff
- testtype: assertresults
Expand Down
2 changes: 1 addition & 1 deletion WebColorPreservation.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Apple has a workaround flag for quicktime files that allows you to explicitly se
`-color_trc unknown -movflags write_colr+write_gama -mov_gamma 2.4` would correctly set the gamma of the media to bt1886 on Apple hardware. You can similarly use this for any other gamma, see: [Color-TRC Comparison for OSX](/EncodingGuidelines/tests/greyramp-osx/compare.html). NOTE, you do need the `-color_trc unknown` so that it knows to fall back on the mov_gamma value.

<!---
name: test_quickstart
name: test_movgama
sources:
- sourceimages/smptehdbars_8.png.yml
comparisontest:
Expand Down

0 comments on commit ecc81aa

Please sign in to comment.