AW: How to make/fix mp4 file can be play on vlc?

Thornton, Keith keith.thornton at zeiss.com
Tue Jul 28 08:42:44 UTC 2020


Hi, fwiw,
as far as the other critic made by gotsring, that MP4 files have the problem that the header block is written to the end of the file so if the end is not written, the file is unplayable, can be counteracted by moving the header to the front. This can only be done if you know how large the recording is going to be, because you have to reserve space at the start of the file. This can be done by using the following mp4muxer parameters
    g_object_set(G_OBJECT(pPrimaryMuxer), "reserved-max-duration", reservedMaxDuration, static_cast<char *>(nullptr));
    g_object_set(G_OBJECT(pPrimaryMuxer), "reserved-moov-update-period", 5000000000UL, static_cast<char *>(nullptr)); // 5 seconds
    g_object_set(G_OBJECT(pPrimaryMuxer), "reserved-bytes-per-sec", 600UL, static_cast<char *>(nullptr));
Gruesse


Von: gstreamer-devel <gstreamer-devel-bounces at lists.freedesktop.org> Im Auftrag von Psychesnet Hsieh
Gesendet: Dienstag, 28. Juli 2020 09:16
An: Discussion of the development of and with GStreamer <gstreamer-devel at lists.freedesktop.org>
Betreff: Re: How to make/fix mp4 file can be play on vlc?

Hi gotsring,

I figure out the problem.
Pipeline need h264parse to convert byte-stream to avc and mp4mux can mix H264 frames as mp4 file.
Thanks a lot.

Psychesnet Hsieh <psychesnet at gmail.com<mailto:psychesnet at gmail.com>> 於 2020年7月28日 週二 上午9:31寫道:
Hi gotsring,

Thanks for the reply.

Our platform did not support MKV mux module on gstreamer component. So, I still need to work on mp4mux.

I double check the option of '-e' from tools/gst-launch.c and I add following code to my testing tool.
1. The duration of mp4 file is over 10 sec, we will send EOS event.
if (((hdr->fpts.tv_sec - app->first_pts.tv_sec >= 10) && (hdr->fpts.tv_usec >= app->first_pts.tv_usec)) ||
            hdr->fpts.tv_sec - app->first_pts.tv_sec > 10)) {
              ok = FALSE;
}
.....
if (ok == FALSE) {
         GST_INFO("send EOS event\n");
        gst_element_send_event(app->pipeline, gst_event_new_eos());
}
2. At message part, when we recv EOS, we will do stop loop.
        case GST_MESSAGE_EOS: {
                                 g_printerr("recv EOS msg\n");
                                 g_main_loop_quit (app->loop);
                                 break;
                              }
3. Double check the log from testing tool, testing tool did send EOS to pipeline.
0:00:09.650924349  1255      0x3611e00 INFO         appsrc-pipeline ringbuf_appsrc.cpp:77:read_data: send EOS event

0:00:09.653614066  1255      0x36b10a0 INFO                    task gsttask.c:312:gst_task_func:<ringbuf:src> Task going to paused
0:00:09.653862576  1255      0x36b10a0 INFO                    task gsttask.c:314:gst_task_func:<ringbuf:src> Task resume from paused
0:00:09.654003645  1255      0x36b10a0 INFO                 basesrc gstbasesrc.c:2854:gst_base_src_loop:<ringbuf> pausing after gst_base_src_get_range() = eos
0:00:09.654223941  1255      0x36b10a0 INFO                    task gsttask.c:312:gst_task_func:<ringbuf:src> Task going to paused
0:00:09.654832350  1255      0x3611e00 INFO         appsrc-pipeline ringbuf_appsrc.cpp:108:bus_message: got message eos
recv EOS msg
0:00:10.655268590  1255      0x3611e00 INFO         appsrc-pipeline ringbuf_appsrc.cpp:215:main: stopping

Add above code, mp4 file still not working on VLC player.
Please provide advise to fix it. Thanks.


gotsring <gotsring at live.com<mailto:gotsring at live.com>> 於 2020年7月28日 週二 上午3:07寫道:
Are you finalizing the MP4 file? This is done by sending an EOS signal
through the pipeline. For the gst-launch command-line tool, just add -e in
the options, like
gst-launch-1.0 -e appsrc name=ringbuf ! mp4mux ! filesink
location=/tmp/opt/h264.mp4

On a side note, I prefer MKV containers instead of MP4 because they tend to
be more resistant to errors. If you don't finalize an MKV file, you can
still play the video, scrubbing or other metadata isn't available. If you
don't finalize the MP4 file, the file is unplayable. MKV files can still
play in VLC, so you'd be good there.

Example:
gst-launch-1.0 -e appsrc name=ringbuf ! matroskamux ! filesink
location=/tmp/opt/h264.mkv

You might need a parser right before the matroskamux, like h264parse.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgstreamer-devel.966125.n4.nabble.com%2F&data=02%7C01%7C%7C48e3d494b40e470b96a308d832d0832b%7C28042244bb514cd680347776fa3703e8%7C1%7C0%7C637315218419022433&sdata=GHYzMHFWuRTfuPSpz6hPPfmUG%2FCdLaJgyh%2BYLX4svRA%3D&reserved=0>
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org<mailto:gstreamer-devel at lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fgstreamer-devel&data=02%7C01%7C%7C48e3d494b40e470b96a308d832d0832b%7C28042244bb514cd680347776fa3703e8%7C1%7C0%7C637315218419032396&sdata=f3Ufu7bxdb6das7Dip2I9OA38yhStWsgFyLi5ttqLRY%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20200728/c3ac4734/attachment-0001.htm>


More information about the gstreamer-devel mailing list