[Libav-user] Redirecting MP4 muxed data to socket using movflags resets timestamp

Parth V Shah parth.vshah at einfochips.com
Mon Sep 1 10:43:18 CEST 2014


I am using FFMPEG library to mux H.264 and AAC frames to MP4 file. I do that C program.
I store H.264 and AAC frame's timestamp in epoch format.

I use ffprobe to check timestamps that stored in the MP4 file, ffprobe confirms that file is in MP4 format and timestamps are stored correctly. below is the output of ffprobe.


  *   ffprobe -show_packets 20140805095931.mp4

        Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20140805095931.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf54.29.104
      Duration: 00:01:39.70, start: 1407232771.984000, bitrate: 1063 kb/s
        Stream #0.0(und): Video: h264 (High), yuv420p, 960x540, 999 kb/s, 30 fps, 59.94 tbr, 1k tbn, 60 tbc
        Stream #0.1(und): Audio: aac, 48000 Hz, mono, s16, 53 kb/s
    [PACKET]
    codec_type=video
    stream_index=0
    pts=1407232771984
    pts_time=1407232771.984000
    dts=1407232771984
    dts_time=1407232771.984000
    duration=34
    duration_time=0.034000
    size=24556.000000
    pos=48
    flags=K
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=1407232772018
    pts_time=1407232772.018000
    dts=1407232772018
    dts_time=1407232772.018000
    duration=33
    duration_time=0.033000
    size=3180.000000
    pos=24604
    flags=_
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=1407232772051
    pts_time=1407232772.051000
    dts=1407232772051
    dts_time=1407232772.051000
    duration=33
    duration_time=0.033000
    size=3209.000000
    pos=27784
    flags=_
    [/PACKET]


My goal is reading this muxed MP4 data from MP4 file and send this muxed mp4 data to the client over socket without creating any temporary file. My actual goal is to write a C program though.

I tried using protocols tcp and udp but they are not working with Mp4 format and gives error as below.

ffmpeg -i 20140805095931.mp4 -f mp4 -vcodec copy tcp://10.99.19.163:8888

[mp4 @ 0xb1e1920] muxer does not support non seekable output
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

So, I read somewhere about moov atom and tried it with following command

ffmpeg -i 20140805095931.mp4 -movflags isml+frag_keyframe -f mp4 -vcodec copy tcp://10.99.19.163:8888

using above commandline I am able to send mp4 file to the client using tcp protocol that ffmpeg supports.

But when I apply ffprobe on the MP4 file timestamp resets to 0 , even starttime becomes 0.0000. Below is the output of ffmpeg.


  *    ffprobe -show_packets out.mp4

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf55.48.100
      Duration: 00:01:39.71, start: 0.000000, bitrate: 1059 kb/s
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 960x540, 999 kb/s, 30 fps, 30 tbr, 16k tbn, 60 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 53 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    [PACKET]
    codec_type=video
    stream_index=0
    pts=0
    pts_time=0.000000
    dts=0
    dts_time=0.000000
    duration=533
    duration_time=0.033313
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=24556
    pos=3853
    flags=K
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=544
    pts_time=0.034000
    dts=544
    dts_time=0.034000
    duration=533
    duration_time=0.033313
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=3180
    pos=28409
    flags=_
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=1072
    pts_time=0.067000
    dts=1072
    dts_time=0.067000
    duration=533
    duration_time=0.033313
    convergence_duration=N/A
    convergence_duration_time=N/A
    size=3209
    pos=31589
    flags=_
    [/PACKET]


Any help or advice? Thank you in advance. ************************************************************************************************************************************************************* eInfochips Business Disclaimer: This e-mail message and all attachments transmitted with it are intended solely for the use of the addressee and may contain legally privileged and confidential information. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately by replying to this message and please delete it from your computer. Any views expressed in this message are those of the individual sender unless otherwise stated. Company has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any virus transmitted by this email. *************************************************************************************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140901/cce8e681/attachment.html>


More information about the Libav-user mailing list