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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Psychesnet Hsieh
Hi all,

We have a share memory which we store raw h264 frames on it.
We write a appsrc testing tool, the behavior like "gst-launch-1.0 appsrc name=ringbuf ! mp4mux ! filesink location=/tmp/opt/h264.mp4".
Double check the h264.mp4 which can be play via gstreamer(playbin) and ffplay, not VLC.

At same time, I use ffprobe to dump the info of h264.mp4, we have
$ ffprobe -i h264.mp4 -v quiet -print_format json -show_format
{
    "format": {
        "filename": "/prefix/s5lwrt/h264.mp4",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "h264",
        "format_long_name": "raw H.264 video",
        "size": "9911102",
        "probe_score": 51
    }
}


I use "ffmpeg -i h264.mp4 -vcodec copy aaa.mp4" to convert it and ffprobe aaa.mp4.
$ ffprobe -i aaa.mp4 -v quiet -print_format json -show_format
{
    "format": {
        "filename": "aaa.mp4",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "10.074000",
        "size": "9915267",
        "bit_rate": "7873946",
        "probe_score": 100,
        "tags": {
            "major_brand": "isom",
            "minor_version": "512",
            "compatible_brands": "isomiso2avc1mp41",
            "encoder": "Lavf58.29.100"
        }
    }
}


Look like the header is quite different. I already use "faststart=TRUE" in my code, still same.
So please give me some advice to fix this problem, need your help. Thanks.

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

gotsring
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/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Psychesnet Hsieh
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 <[hidden email]> 於 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/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Psychesnet Hsieh
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 <[hidden email]> 於 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 <[hidden email]> 於 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/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Thornton, Keith

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 <[hidden email]> Im Auftrag von Psychesnet Hsieh
Gesendet: Dienstag, 28. Juli 2020 09:16
An: Discussion of the development of and with GStreamer <[hidden email]>
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 <[hidden email]> 2020728日 週二 上午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 <[hidden email]> 2020728日 週二 上午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/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel