Video and audio are not synchronized in mp4 container

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Video and audio are not synchronized in mp4 container

sonntex
I have small utility that reads annex-b h264 and adts aac streams from two pipes and writes them to one mp4 container. Both pipes have live streams from v4l2 and alsa devices. As you can see, I added is-live property to fdsrc. Without this property pts and dts of the video stream were corrupted.


#!/bin/sh

timeout=60

usage() {
    echo "Usage: $(basename $0) [OPTIONS] <VIDEOPIPE> <AUDIOPIPE> <MASK>"
    echo "  -o arg (=$timeout) timeout"

    exit 0
}

OPTIND=1

while getopts "o:" opt

do
    case $opt in
        o)  timeout=$OPTARG
            ;;
        *)  usage
            ;;
    esac
done

shift $((OPTIND-1))

[ $# -ne 3 ] && usage

video_pipe="$1"
audio_pipe="$2"
mask="$3"

exec 3<> "$video_pipe"
exec 4<> "$audio_pipe"

gst-launch-1.0 -qe \
    fdsrc fd=3 do-timestamp=true is-live=true \
  ! queue \
  ! h264parse \
  !     video/x-h264,stream-format=avc,alignment=au \
  ! mux.video \
    fdsrc fd=4 do-timestamp=true is-live=true \
  ! queue \
  ! aacparse \
  !     audio/mpeg,stream-format=raw \
  ! mux.audio_0 \
    splitmuxsink name=mux location="$mask" max-size-time="${timeout}000000000"


The problem is that video and audio streams in mp4 file are not synchronized (or something else). Video looks good, but audio stream has periodically pauses about one second long. There are same pauses in audio stream after remuxing it from mp4 container with audio and video streams to another mp4 container without video stream. But result is good if I first mux only audio stream from audio pipe to mp4 container without video stream. So, I think that video stream affects to this problem.

I already tryed to set sync property of splitmuxsink to true or false. It did not help.

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