storing one video stream into multiple files
Jaroslav Klaus
jaroslav.klaus at gmail.com
Thu Feb 2 08:53:16 PST 2012
Hi,
Do you really need mp4 container? I don't believe multifilesink will work with mp4mux out of the box. Transport stream is definitely much better.
If you really need MP4 I would take a look in lighttp's code for h.264/mp4 streaming (http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming) to repeat mp4 atoms.
jk
On 2. 2. 2012, at 17:39, Jan Spurny wrote:
> Hi,
>
> thanks for reply, this is definitely working, but I need solution within gstreamer pipeline.
> So I just have to look into ffmpeg sources and then replicate this functionality in my new element..
>
> Jan Spurny
>
> On Thu, 02 Feb 2012 16:31:13 +0100 (CET)
> Angel Martin <amartin at vicomtech.org> wrote:
>
>> Hi,
>>
>> First of all, I am not sure that you could do this process in this place of
>> the pipeline where you are trying to, because you don't control there when
>> a Intra frame comes, so the files could not be correctly visualized later.
>>
>> Maybe this solution, based on ffmpeg, could fix your problem:
>> http://ffmpeg.org/ffmpeg.html#segment
>>
>> You can find a more contextualized explanation here:
>> http://forums.creativecow.net/thread/291/616
>>
>> Best,
>>
>> Angel
>>
>> 2012/2/2 Jan Spurny <JSpurny at seznam.cz>
>>
>>> Hi,
>>>
>>> thanks for reply, at first I thought that multifilesink was only useful
>>> for dumping single frames, but than I found out it allows file splitting
>>> not only on buffer boundary, but also on discontinuity (?? I don't really
>>> know what that means) or key-frame.
>>> Using key-frame as a boundary seems to work, but only with mpeg ts
>>> streams, but I was only able to split incoming stream. When I tried some
>>> re-encoding the pipeline has failed.
>>> So it's a good start, but this way I have no control over the size of
>>> resulting files and also I'm stuck with original stream format.
>>>
>>> For example, this "works" (vid.avi containst h264 stream):
>>>
>>> gst-launch filesrc location=vid.avi \
>>> ! avidemux \
>>> ! mpegtsmux \
>>> ! multifilesink next-file=key-frame location=file-%03d.mpg
>>>
>>> and resulting mpeg files are playable, but as I said, I'll have many
>>> different inputs and I need to re-encode the stream to some default format,
>>> so when I tried this to get 30s fragments with h264:
>>>
>>> gst-launch filesrc location=vid.avi \
>>> ! decodebin \
>>> ! x264enc \
>>> ! mp4mux fragment-duration=30000 \
>>> ! multifilesink next-file=key-frame location=file-%03d.mp4
>>>
>>> then I got first mp4 file which looks fine and I can play it, but the
>>> others are somehow invalid and I can't play them.
>>>
>>> It seems to me that while mp4mux and multifilesink works fine together,
>>> some crucial mp4 header is lost for all but the first file.
>>>
>>> Also the first playable file segment has length of 10 seconds regardless
>>> of the specified "fragment-duration", so I probably got this one wrong..
>>> And to make things even stranger, without "fragment-duration" option, even
>>> the first file is not playable..
>>>
>>> Anyway, it seems that I'm at least moving in the right direction..
>>>
>>>
>>> Jan Spurny
>>>
>>> On Thu, 02 Feb 2012 09:43:44 +0100 (CET)
>>> Garbriel Neumüller <horsthuchen at googlemail.com> wrote:
>>>
>>>> Hi,
>>>> do you know the Multifilesink plugin?
>>>> I think it would do exactly what you expect .
>>>> I never used it by my own but it sounds quite well.
>>>>
>>>>
>>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von:
>>>> gstreamer-devel-bounces+horsthuchen=googlemail.com at lists.freedesktop.org
>>>> [mailto:gstreamer-devel-bounces+horsthuchen
>>> =googlemail.com at lists.freedesktop
>>>> .org] Im Auftrag von Jan Spurny
>>>> Gesendet: Mittwoch, 1. Februar 2012 12:01
>>>> An: gstreamer-devel at lists.freedesktop.org
>>>> Betreff: storing one video stream into multiple files
>>>>
>>>> Hi,
>>>>
>>>> I'm trying to store video from one video stream into multiple files with
>>>> given duration.
>>>> Something which could look like this:
>>>>
>>>> gst-launch souphttpsrc location=http://1.2.3.4/video1 ! decodebin !
>>> x264enc
>>>> ! SOMETHING filename="file_%D_%T.mp4" duration=2m
>>>>
>>>> and it would produce files like these:
>>>>
>>>> file_2012-02-01_10-12-43.mp4
>>>> file_2012-02-01_10-14-43.mp4
>>>> file_2012-02-01_10-16-43.mp4
>>>> ..
>>>>
>>>> I don't expect that element "SOMETHING" already exists so I'll have to
>>> write
>>>> it myself. I have written a few simple gstreamer elements (mostly some
>>> kind
>>>> of raw-video transformations) so I'm quite confident I'll be able to do
>>> it,
>>>> but I do need all advices and guidelines I can get.
>>>>
>>>> I'll have many different inputs - different input sources (files, http
>>>> streams, rtsp streams, v4l, ..) and also different input formats (mjpeg,
>>>> mpeg4, h264, raw-yuv). But that's ok, gstreamer can handle these without
>>>> problems.
>>>>
>>>> Now I can either just simply reuse the stream and just "cut it into
>>> chunks
>>>> of desired length", but as there are so many different formats to work
>>>> with..
>>>> Or I'll just recode video into some default format. That's why I have a
>>>> "decodebin ! x264enc" in my pipeline above. I may support more formats in
>>>> the future but for the first version one is enough.
>>>>
>>>> So with one known format (let's say h264) I'll have to "pack it" (muxer)
>>>> into small chunks and write them down to disk.
>>>>
>>>> This is the part where I don't really know where to start - I guess
>>> studying
>>>> some existing muxer and would be a good start, but I'm really scared of
>>> all
>>>> the complexity with encoded video streams, B-frames, I-frames, and all
>>>> this..
>>>>
>>>>
>>>> Thanks in advance for any help, advices or suggestions.
>>>>
>>>> Jan Spurny
>>>> _______________________________________________
>>>> gstreamer-devel mailing list
>>>> gstreamer-devel at lists.freedesktop.org
>>>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>>>
>>>> _______________________________________________
>>>> gstreamer-devel mailing list
>>>> gstreamer-devel at lists.freedesktop.org
>>>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> gstreamer-devel at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list