sannies / mp4parser

A Java API to read, write and create MP4 files
Apache License 2.0
2.76k stars 566 forks source link

H264TrackImpl AACTrackImpl create mp4 can not play in VLC #319

Closed shoyu666 closed 6 years ago

shoyu666 commented 6 years ago

dear author use H264TrackImpl and AACTrackImpl create mp4

final 1532667754113A2.mp4 can not play int 'vlc' why? but can play in 'windows media player'

` public class Mux { public static void main(String[] args) throws IOException, XPathExpressionException, SAXException, ParserConfigurationException, URISyntaxException { String fileName = "C:\Users\n\Desktop\h264\test\1532667754113"; Movie v = new Movie(); Track audio = new H264TrackImpl(new FileDataSourceImpl(fileName+".h264")); v.addTrack(audio); AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl(fileName+".aac")); v.addTrack(aacTrack); Mp4Builder defaultMp4Builder = new DefaultMp4Builder(); Container c = defaultMp4Builder.build(v); File out = new File(fileName+"A2.mp4"); c.writeContainer(new FileOutputStream(out).getChannel()); } }

`

test.zip

sannies commented 6 years ago

Hmm, not sure what the problem might be here. Would you please verify that C:\Users\n\Desktop\h264\test\1532667754113 plays in VLC? C:\Users\n\Desktop\h264\test\1532667754113 should be an Annex B bitstream. What kind of file is C:\Users\n\Desktop\h264\test\1532667754113?

2018-07-27 8:36 GMT+02:00 shoyu666 notifications@github.com:

use H264TrackImpl and AACTrackImpl create mp4

final 1532667754113A2.mp4 can not play int 'vlc' but can play in 'windows media player'

// String fileName = "C:\Users\n\Desktop\h264\test\1532667754113"; Movie v = new Movie(); Track audio = new H264TrackImpl(new FileDataSourceImpl(fileName+".h264")); v.addTrack(audio);

AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl(fileName+".aac"));
v.addTrack(aacTrack);

// Mp4Builder defaultMp4Builder = new DefaultMp4Builder(); Container c = defaultMp4Builder.build(v); File out = new File(fileName+"A2.mp4"); c.writeContainer(new FileOutputStream(out).getChannel()); // Mp4Builder defaultMp4Builder = new DefaultMp4Builder(); Container c = defaultMp4Builder.build(v); File out = new File(fileName+"A2.mp4"); c.writeContainer(new FileOutputStream(out).getChannel()); //

test.zip https://github.com/sannies/mp4parser/files/2234731/test.zip

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sannies/mp4parser/issues/319, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKUD1dvc4Tl73WQmH_mzQ4TXdiC3IVPks5uKrTvgaJpZM4Vi_Go .

shoyu666 commented 6 years ago

@sannies thanks for you reply (I am sorry for my poor english) i has upload a zip 1532667754113 .aac 1532667754113 .h264

i try create mp4 (1532667754113 .aac+1532667754113 .h264) i try create mp4 (1532667754113 .h264) can not play in vlc(https://www.videolan.org/) can not play in mac need you help

files.zip

sannies commented 6 years ago

Please make the h264 file available to me.

shoyu666 commented 6 years ago

dear author --Please make the h264 file available to me. do you mean h264 soure file? can you see zip file i have upload ?

shoyu666 commented 6 years ago

@sannies i get raw h264 file by android MediaCodec in front i wirte write outputFormat.getByteBuffer("csd-0") write outputFormat.getByteBuffer("csd-1")

write MediaCodec OutputBuffer data;

write MediaCodec OutputBuffer data; .................. write MediaCodec OutputBuffer data;

by the way .h264 can play in vlc

sannies commented 6 years ago

got it, sorry. didn't see the zip

shoyu666 commented 6 years ago

@sannies thanks, ; possible causes i am in china

i upload to github https://github.com/shoyu666/Hand-Signature/blob/master/files.zip can you down load ?

sannies commented 6 years ago

The H264TrackImpl didn't correctly parse the Sample objects from the file as it didn't set the SampleDescription thus it could set the sample derscription index correctly when writing the MP4. I published 1.9.36 with that fix.