sannies / mp4parser

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

convert H264AnnexBTrack to FragmentedMp4Writer #388

Open ashraf-revo opened 5 years ago

ashraf-revo commented 5 years ago

i have write this code to convert H264AnnexBTrack to FragmentedMp4Writer

    FileInputStream stream = new FileInputStream(new File("/media/ashraf/WorkSpace/IdeaProjects/streamer/m.h264"));
    H264AnnexBTrack h264AnnexBTrack = new H264AnnexBTrack(stream);
    WritableByteChannel channel = new FileOutputStream(new File("output.mp4")).getChannel();
    FragmentedMp4Writer writer = new FragmentedMp4Writer(Collections.singletonList(h264AnnexBTrack), channel);
    h264AnnexBTrack.call();
    writer.close();

but the generated file not work it's a bad file

yesennes commented 3 years ago

I'm having the same issue running mp4parser/examples/src/main/java/org/mp4parser/examples/mux/streaming/H264AACExample.java . Ffprobe gives

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x105c5a0] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 500x208): unspecified pixel format

When I try it on the result, and vlc doesn't play it.