how to convert .mp4 to .ts use gst-launch-1.x

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

how to convert .mp4 to .ts use gst-launch-1.x

gang
Hello, all,  I have a problem when I tried to conver a .mp4 file to .ts, here is the detail:
------------------------------------
name$ avprobe why.mp4
avprobe version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2007-2014 the Libav developers
  built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'why.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2011-02-07 08:15:04
  Duration: 00:03:25.74, start: 0.000000, bitrate: 6000 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 5866 kb/s, 23.98 fps, 24 tbr, 1k tbn, 47.95 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0.1(und): Audio: aac, 44100 Hz, stereo, fltp, 127 kb/s
    Metadata:
      creation_time   : 2011-02-07 08:15:08
# avprobe output
------------------------------------

It looks everything is ok, so I use command:

gst-launch-0.10 filesrc location=why.mp4 ! decodebin2 name=dec ! queue ! x264enc ! mpegtsmux name=mux ! filesink location=1.ts dec. ! queue ! audioconvert ! ffenc_aac ! mux.

and the result is:
------------------------------------
name$ avprobe 1.ts
avprobe version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2007-2014 the Libav developers
  built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[aac @ 0x23e4fa0] Input buffer exhausted before END element found
[mpegts @ 0x23ddc00] Non-increasing DTS in stream 0: packet 22 with DTS 86310, packet 23 with DTS 86310
[mpegts @ 0x23ddc00] Non-increasing DTS in stream 0: packet 25 with DTS 97560, packet 26 with DTS 97560
[mpegts @ 0x23ddc00] Non-increasing DTS in stream 0: packet 29 with DTS 112590, packet 30 with DTS 112590
[mpegts @ 0x23ddc00] Non-increasing DTS in stream 0: packet 75 with DTS 285300, packet 76 with DTS 285300
[mpegts @ 0x23ddc00] max_analyze_duration reached
Input #0, mpegts, from '1.ts':
  Duration: 00:03:25.70, start: 0.000000, bitrate: 2134 kb/s
  Program 1
    Stream #0.0[0x41]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 23.42 fps, 1k tbr, 90k tbn, 1073741824 tbc
    Stream #0.1[0x40]: Audio: aac, 44100 Hz, stereo, fltp, 129 kb/s
[h264 @ 0x23e54a0] Ignoring NAL unit 9 during extradata parsing
# avprobe output
------------------------------------

also looks nice except some warnings, but when I use gst-launch-1.0(include 1.0.10, 1.2.4 and 1.4.5),
I used command :

gst-launch-1.0 filesrc location=why.mp4 ! qtdemux name=dec ! queue ! avdec_h264 ! queue ! x264enc ! mpegtsmux name=mux ! filesink location=1.ts dec. ! queue ! audioconvert ! avenc_aac ! mux.

output:
------------------------------------
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
------------------------------------
waited for ten minutes, nothing else...
but if I only transcode video, like:

 gst-launch-1.0 filesrc location=why.mp4 ! qtdemux name=dec ! queue ! avdec_h264 ! queue ! x264enc ! mpegtsmux name=mux ! filesink location=1.ts(just delete audio process)

it works well, but start time of 1.ts is 3600:
------------------------------------
name$ avprobe 1.ts
[mpegts @ 0xee7c60] Invalid timestamps stream=0, pts=324082620, dts=324086310, size=2463
[mpegts @ 0xee7c60] Invalid timestamps stream=0, pts=324093870, dts=324097560, size=2847
[mpegts @ 0xee7c60] Invalid timestamps stream=0, pts=324108900, dts=324112590, size=2372
[mpegts @ 0xee7c60] Invalid timestamps stream=0, pts=324281520, dts=324285210, size=4271
[mpegts @ 0xee7c60] Invalid timestamps stream=0, pts=324446670, dts=324450540, size=2918
[mpegts @ 0xee7c60] Invalid timestamps stream=0, pts=324457920, dts=324458010, size=6939
[mpegts @ 0xee7c60] Invalid timestamps stream=0, pts=324461700, dts=324461790, size=7241
Input #0, mpegts, from '1.ts':
  Duration: 00:03:25.75, start: 3600.000000, bitrate: 1957 kb/s
  Program 1
    Stream #0:0[0x41]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k
tbn, 2000000000.00 tbc
------------------------------------

I there something wrong when I use gstreamer ? plz help me!
Reply | Threaded
Open this post in threaded view
|

Re: how to convert .mp4 to .ts use gst-launch-1.x

gang
os platform:CentOS 7.0

so,who can help me ?
Reply | Threaded
Open this post in threaded view
|

Re: how to convert .mp4 to .ts use gst-launch-1.x

knorr
Hello,

In this pipeline

*gst-launch-1.0 filesrc location=why.mp4 ! qtdemux name=dec ! queue !
avdec_h264 ! queue ! x264enc ! mpegtsmux name=mux ! filesink location=1.ts
dec. ! queue ! audioconvert ! avenc_aac ! mux.*

you are not actually decoding the audio before you try to re-encode it. audioconvert only converts between raw audio formats.

Any particular reason why you want to re-encode audio and video? You should be able to make the transport stream without transcoding.

Something like

gst-launch-1.0 filesrc location=why.mp4 ! qtdemux name=d ! queue ! h264parse ! mpegtsmux name=mux ! filesink location=1.ts d. ! queue ! aacparse ! mux.

The start time at 3600 is a fixed offset used in mpegtsmux to give some slack.

Best Regards
Jesper

On Mon, Mar 23, 2015 at 2:13 AM, gang <[hidden email]> wrote:
os platform:CentOS 7.0

so,who can help me ?



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/how-to-convert-mp4-to-ts-use-gst-launch-1-x-tp4671263p4671265.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


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

Re: how to convert .mp4 to .ts use gst-launch-1.x

gang
thanks very much for your replay, Jesper.
I re-encoded it because I want to change the file's bitrate and resolution.

About this sentence: "The start time at 3600 is a fixed offset used in mpegtsmux to give some slack.", how could I comprehend it ?
Reply | Threaded
Open this post in threaded view
|

Re: how to convert .mp4 to .ts use gst-launch-1.x

knorr
I do not know the exact details of the offset.

The comments in the source code indicates that the offset is added in order to give some room for time going backwards.

On Wed, Mar 25, 2015 at 2:58 AM, gang <[hidden email]> wrote:
thanks very much for your replay, Jesper.
I re-encoded it because I want to change the file's bitrate and resolution.

About this sentence: "The start time at 3600 is a fixed offset used in
mpegtsmux to give some slack.", how could I comprehend it ?



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/how-to-convert-mp4-to-ts-use-gst-launch-1-x-tp4671263p4671301.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


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

Re: how to convert .mp4 to .ts use gst-launch-1.x

gang
Thank you very much, I've got it
Reply | Threaded
Open this post in threaded view
|

Re: how to convert .mp4 to .ts use gst-launch-1.x

endeavorfrazer
In reply to this post by gang
You may also try iDealshare VideoGo to convert MP4 to TS with this easy guide https://www.idealshare.net/video-converter/mp4-to-ts-converter.html
Reply | Threaded
Open this post in threaded view
|

Re: how to convert .mp4 to .ts use gst-launch-1.x

naseeb_panghal
In reply to this post by knorr
I used the pipeline provided but it gives below error.
Pipeline:
gst-launch-1.0 filesrc location=why.mp4 ! qtdemux name=d ! queue !
h264parse ! mpegtsmux name=mux ! filesink location=1.ts d. ! queue !
aacparse ! mux.

New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.384016374
knorr wrote
Hello,

In this pipeline

*gst-launch-1.0 filesrc location=why.mp4 ! qtdemux name=dec ! queue !
avdec_h264 ! queue ! x264enc ! mpegtsmux name=mux ! filesink location=1.ts
dec. ! queue ! audioconvert ! avenc_aac ! mux.*

you are not actually decoding the audio before you try to re-encode it.
audioconvert only converts between raw audio formats.

Any particular reason why you want to re-encode audio and video? You should
be able to make the transport stream without transcoding.

Something like

gst-launch-1.0 filesrc location=why.mp4 ! qtdemux name=d ! queue !
h264parse ! mpegtsmux name=mux ! filesink location=1.ts d. ! queue !
aacparse ! mux.

The start time at 3600 is a fixed offset used in mpegtsmux to give some
slack.

Best Regards
Jesper

On Mon, Mar 23, 2015 at 2:13 AM, gang <[hidden email]> wrote:

> os platform:CentOS 7.0
>
> so,who can help me ?
>
>
>
> --
> View this message in context:
> http://gstreamer-devel.966125.n4.nabble.com/how-to-convert-mp4-to-ts-use-gst-launch-1-x-tp4671263p4671265.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>

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

Re: how to convert .mp4 to .ts use gst-launch-1.x

Kirill Sprinchan
In reply to this post by gang
gst-launch-1.0 -e filesrc location={FROM.mp4} ! qtdemux name=demux mpegtsmux
name=mux ! filesink location=/{TO.ts}  demux.video_0 ! h264parse ! queue !
mux.  demux.audio_0 ! queue ! mux.


Works for me.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel