我有这个使用Android MediaRecorder记录音频文件的Android应用程序(compileSdkVersion 23,minSdkVersion 16,targetSdkVersion 23)。
这是我开始录制的方式
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mMediaRecorder.setAudioChannels(2);
mMediaRecorder.setMaxDuration(mMaxRecordLength);
mMediaRecorder.setAudioSamplingRate(44100);
mMediaRecorder.setAudioEncodingBitRate(96000);
mMediaRecorder.setOutputFile(mFileName);
mMediaRecorder.prepare();
mMediaRecorder.start();
以及我停止录制的方式
mMediaRecorder.stop();
mMediaRecorder.reset();
mMediaRecorder.release();
问题:
当录制的音频超过1分50秒时,文件的标题似乎会遗漏一些有关文件内容的信息;我需要在播放器上播放这些文件,该播放器检查文件内的信息(不仅是文件扩展名),这样,当持续时间大于1时,它无法识别我录制的文件:50分钟。
我记录了许多长度的文件,以了解发生了什么,最后我用十六进制编辑器打开文件,这就是我发现的:
文件长度1:50分钟或少[好文件]:
....ftypmp42....isommp42..T.moov...lm
vhd..................................
..................................@..
................................ymeta
...!hdlr........mdta................+
keys............mdtacom.android.versi
on...%ilst............data........6.0
.1..S.trak...\tkhd...................
.....................................
................@.............Scmdia.
.. mdhd...............D.Jk........,hd
lr........soun............SoundHandle
...S.minf....smhd...........$dinf....
dref............url ......R.stbl...[s
tsd...........Kmp4a..................
.......D.....'esds...........@......w
...w............stts.................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
[CUT of so many dots and not much more]
.....................................
.....................................
.....................................
......V...#........stsc..............
..........stco..........T....'free...
..............................A.mdat.
@"....------------------------------
-------------------------------------
-------------------------------------
-------------------------------------
-------------------------------------
-------------------------------------
-------------------------------------
---------------.....6.tfZ...........(
.Q*k...P..@.........?.H.....H\a...H=.
.?.H.R..4a...7.....cTB~O.._e.......
......Z!.=s462.e.]."b...|a..[...uK...
...g.. .q.W,..6[...KO.R.j.5@W....B9dj
1B....UK,.K3[-.=..;3...x.3.;r.u....|
.)......."..e.YA.r..Y@.f..y...<.R.).,
.:.....<..)..UT..X5.Q)..UTb2...5.....
...C.b=.7.O....yk.M...gH.=.`z.0..X..4
S....j.G.\....|...DI.d....QE...6*....
T....TD....Q*...|..~..z.........:.W.v
...w..m.9n......Yw..(PRRWm..Z.*..&.f.
.....\;[.c]YY#[53AC9.=..R.j...)5.....
...:.....R.A'&jYR...SEb....Ef..f.cEy.
v.J3.d...P../2.....-.d..MR.;4jb..)EbA
r.......Q%5.......2.A..,!.EEe?.tO...
..e......C.$......N.Q..QB..I1i%...3T.
...C..d"Q.*2..<........S.4...{H...]..
....!4.N...Mr... ..ze"..%=..~....r`F;
....2.......M.....6)..4...a .*.\.....
.P.JE].EM.....}X.My~..z..k.;^_.......
N...._...=..:..pd5.._H..... L.?...nk.
W.n1.Ct^....m...?WnR..........`F{.~.Y
2..V....`\.GCL......)1..<..4...l))...
8%..0J....g..V....9.;..H'.%4...!.E%.P
.W ....x...8...........BL.Y..1.A.eL.
...Xf.&...'w....c...nY.<7 .z.........
.)....a..!.7O.........O...X....8...6
)......A1./-.fq.Wc-WWK..J.r.:.G.|_6..
_.<....T-...A.y...........hw..m..F.
.F.........n....L..D...m.e..n..S)....
...ia...@....F..............v...I....
.s;bb&...J.&.!w.)..@.M.Z[*.:e=.....(.
.1.1I.&...........r.f...xR..!....H...
[Y.......A}..#..`*..+.....S.A...C...
TYtI;.y2.w....u.P./.J.3..."....[2V..K
...C...6*....B..#u....u..%".T.R.D.}.'
.nZ..\.`.............o.........3..md
...A.!J.$....sF.S-...........=/]Mg...
...]].......zm.....DE.d.e=.T...B.....
...[..s>.+:0......O...:..A8..S....8..
6W)....Ue..s.....`eC......,'\LzMa...
...w........_.+I.q.u-g...X.o(.....w..
.,.)..>t..rH8E......I...H.C.i.S.-..8.
p..6*.....Vn....X.*A..........$..@..q
\..|.Cl..2..B.........zi.p.q.3....)..
-..m%..B.].pm..f...~a)x...R.E;.c.....
..=P......l|.........:.+Mj...}.b6.N..
W.......kY..,v6`....EH_p...d..X..w.p.
[and so on]
文件长度1:51分钟或更多[坏文件]:
....ftypmp42....isommp42..T.free.....
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
.....................................
[CUT of so many dots and nothing else]
.....................................
.....................................
..............................kumdat.
@"....------------------------------
-------------------------------------
-------------------------------------
-------------------------------------
-------------------------------------
-------------------------------------
-------------------------------------
---------------.....6-......"0P&&D...
Q*.t(J..d.....5x...Y.}m..'...Z`....~.
..w...d.J.N....y./.\..|U:>....Ol.}[(.
..Qe.v.\...gq..7..N..5..K.Au>......>3
.cr.I.....a....=Y..A..9As........U.[.
..RK..15#[g... .....@.....F"....@8...
>Fb.~<.nY...n#..S..#...W0....|..0...S
...Q]$t..J..$_PN.._y..I...}.=..t....
VfP..|?p?]N...6-t8M...P...\.."!.*....
........U2.>7......s...~n...[..%....)
..o..W...V.+.-.r*....E....C&.z..l.}..
Qzr.G...|.D.....^.u.6^5q..`....J..8..
._.....kIV?%.T.......&......Bg$.(.N.O
.N. d,E).2..d...E/.-.!..d.....H.`*,..
..vr....-0...@^....dUME!.l....K..m...
...T.......
A.....Y..\..Os-#X..j^.....R|n.......
^...9..._U..D.s.
.e.F^.,....8..6)V(."..aA.p.(..9.....L
.Q..w.t.R.....EK%8w...1{...Uyo.....PN
.p..........w..~.V.1...y.#.i...).....
.6.@..(9n..&u%.o..q..<.Z7.......&Q.B.
M....<..A...nM..b8...E .=..C..;\...$
.....lD..`0...H..z....A.e........C..c
..zv...d...1.Qy..p.(L.3"A.g../.....7.
.......3.j+_%b.G......QX'....'..,.3.j
.T.........SZ^.tIe..X...Z/......Z..2.
S.8..6).....Ac.."..sZ....uQ...b.[.:^.
.6G+..}....n7.|F..T9._.2"N.g....*....
."R..iZ....9.Z..B.s$...<.N.:...L...
......9w.x...Dt..3,Iy........85....(.
.'..9..F*.w..p..&#....P...)...&....H.
p.....KL.
.@.....z...-.:[...A5.9@....kb...T.ke.
a_~.4.#P.Or..$.I...9..8...Q[A.Xu+..f.
.&9...6.4.<...A.. ..72.}9.r.TT...P...
,n.+....N........Mx.~z..s}.7..nw.,..
.Q.v...z_x........+q.{.~M._....DL...
i.9y..Y6v(..3h.....5.t..d.c....7..*(
pt..3T..=1(."...,.Y..1c....5.....I6..
V.J....-..$4Z.o.E3..1....w,.(..K&...|
..0s.....w.T~...f......y.Tq.$.r5{....
.FB...,......./...Ig-5%..B`$.Y.oF...
..6*.x....a8.,b....2Ew......"RT..M.V.
.Z..N...}...F._......3....2<...r..SI"
..`.......s[.$.T...Q.h$b{.k-x..]..+..
.YA.)p. $&..Du.....wWZ....B_$o...a:..
j2.._.;2n.&p....qy~.wQ,.E..ag9..7}.
.....5.P.kC..yzx^...9.<.z...D]TS..4Z.
[and so on]
正如你在BAD FILE中看到的那样,在第一行之后有一堆点在GOOD FILE中有信息。
你能解释一下我发生了什么,我该怎么做才能解决我的问题?