|
21 | 21 | /** |
22 | 22 | * MP4 muxer that builds a standard MP4 file from DASH fragmented MP4 sources. |
23 | 23 | * |
24 | | - * @author kapodamy |
| 24 | + * <p> |
| 25 | + * See <a href="https://atomicparsley.sourceforge.net/mpeg-4files.html"> |
| 26 | + * https://atomicparsley.sourceforge.net/mpeg-4files.html</a> for information on |
| 27 | + * the MP4 file format and its specification. |
| 28 | + * </p> |
25 | 29 | * |
26 | | - * @implNote See <a href="https://atomicparsley.sourceforge.net/mpeg-4files.html"> |
27 | | - * https://atomicparsley.sourceforge.net/mpeg-4files.html</a> for information on |
28 | | - * the MP4 file format and its specification. |
| 30 | + * @author kapodamy |
29 | 31 | */ |
30 | 32 | public class Mp4FromDashWriter { |
31 | 33 | private static final int EPOCH_OFFSET = 2082844800; |
@@ -783,7 +785,7 @@ private void makeTrak(final int index, final long duration, final int defaultMed |
783 | 785 | final int mediaTime; |
784 | 786 |
|
785 | 787 | if (tracks[index].trak.edstElst == null) { |
786 | | - // is a audio track ¿is edst/elst optional for audio tracks? |
| 788 | + // is an audio track; is edst/elst optional for audio tracks? |
787 | 789 | mediaTime = 0x00; // ffmpeg set this value as zero, instead of defaultMediaTime |
788 | 790 | bMediaRate = 0x00010000; |
789 | 791 | } else { |
@@ -891,28 +893,35 @@ private int makeSbgp() throws IOException { |
891 | 893 | return offset + 0x14; |
892 | 894 | } |
893 | 895 |
|
| 896 | + /** |
| 897 | + * Creates a Sample Group Description Box. |
| 898 | + * |
| 899 | + * <p> |
| 900 | + * What does it do? |
| 901 | + * <br> |
| 902 | + * The table inside of this box gives information about the |
| 903 | + * characteristics of sample groups. The descriptive information is any other |
| 904 | + * information needed to define or characterize the sample group. |
| 905 | + * </p> |
| 906 | + * |
| 907 | + * <p> |
| 908 | + * ¿is replicable this box? |
| 909 | + * <br> |
| 910 | + * NO due lacks of documentation about this box but... |
| 911 | + * most of m4a encoders and ffmpeg uses this box with dummy values (same values) |
| 912 | + * </p> |
| 913 | + * |
| 914 | + * @return byte array with the 'sgpd' box |
| 915 | + */ |
894 | 916 | private byte[] makeSgpd() { |
895 | | - /* |
896 | | - * Sample Group Description Box |
897 | | - * |
898 | | - * ¿whats does? |
899 | | - * the table inside of this box gives information about the |
900 | | - * characteristics of sample groups. The descriptive information is any other |
901 | | - * information needed to define or characterize the sample group. |
902 | | - * |
903 | | - * ¿is replicable this box? |
904 | | - * NO due lacks of documentation about this box but... |
905 | | - * most of m4a encoders and ffmpeg uses this box with dummy values (same values) |
906 | | - */ |
907 | | - |
908 | 917 | final ByteBuffer buffer = ByteBuffer.wrap(new byte[] { |
909 | 918 | 0x00, 0x00, 0x00, 0x1A, // box size |
910 | 919 | 0x73, 0x67, 0x70, 0x64, // "sgpd" |
911 | 920 | 0x01, 0x00, 0x00, 0x00, // box flags (unknown flag sets) |
912 | | - 0x72, 0x6F, 0x6C, 0x6C, // ¿¿group type?? |
913 | | - 0x00, 0x00, 0x00, 0x02, // ¿¿?? |
914 | | - 0x00, 0x00, 0x00, 0x01, // ¿¿?? |
915 | | - (byte) 0xFF, (byte) 0xFF // ¿¿?? |
| 921 | + 0x72, 0x6F, 0x6C, 0x6C, // group type?? |
| 922 | + 0x00, 0x00, 0x00, 0x02, // ?? |
| 923 | + 0x00, 0x00, 0x00, 0x01, // ?? |
| 924 | + (byte) 0xFF, (byte) 0xFF // ?? |
916 | 925 | }); |
917 | 926 |
|
918 | 927 | return buffer.array(); |
@@ -955,6 +964,7 @@ private void makeUdta() throws IOException { |
955 | 964 | writeMetaItem("©ART", artist); |
956 | 965 | } |
957 | 966 | if (date != null && !date.isEmpty()) { |
| 967 | + // this means 'year' in mp4 metadata, who the hell thought that? |
958 | 968 | writeMetaItem("©day", date); |
959 | 969 | } |
960 | 970 |
|
@@ -1037,8 +1047,11 @@ private byte[] makeMetaHdlr() { |
1037 | 1047 | } |
1038 | 1048 |
|
1039 | 1049 | /** |
1040 | | - * Helper to write cover image inside the 'udta' box. |
1041 | | - * |
| 1050 | + * Helper to add cover image inside the 'udta' box. |
| 1051 | + * <p> |
| 1052 | + * This method writes the 'covr' metadata item which contains the cover image. |
| 1053 | + * The cover image is displayed as thumbnail in many media players and file managers. |
| 1054 | + * </p> |
1042 | 1055 | * <pre> |
1043 | 1056 | * [size][key] [data_box] |
1044 | 1057 | * data_box = [size]["data"][type(4bytes)][locale(4bytes)=0][payload] |
|
0 commit comments