[Libav-user] Muxing to file with unknown frame rate

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

[Libav-user] Muxing to file with unknown frame rate

Robert Jamieson

Hi,


I am attempting to mux footage from a variety of webcams into standards based files. The footage is spread over a large number of files (all from the same camera). The files are a proprietary format containing the encoded frames that came directly from the camera (in most cases it is H.264, MJPEG or MPEG4 with G.711 or PCM16 audio). Audio is optional.


I have created a pipeline for processing the footage that comprises of a reader for the files (this reads the frames and pushes them through the pipeline), a file sync that picks a suitable file format (based on the incoming video and audio formats) and writes the already encoded frames into the file. I am purposely not using a transcoder to save processing time.


This is working well with one exception, I can't tell what the frame rate is ahead of time because I can't read the files before I process them. If I set the frame rate to what I suspect the camera will give me (i.e. 30 fps) then I get collisions in PTS values if the camera has been bursty or the fps is actually higher and I drop frames (which may or may not be key frames).


I have tried setting the time_base of the video stream to 1/1000 and calculating the frame pts based on the millisecond timestamp. This works in theory but in practice the only player that can handle playing this back successfully is Media Player Classic and all the files report a frame rate of 1000 (which is understandable).


I am currently alternating between .mkv, .mp4 and .avi depending on the incoming codecs. .mp4 for h.264 or MPEG4 only, avi for h.264, MJEPG or MPEG4 with PCM audio and mkv as a fallback for all other cases.


1. Is there any way to achieve this?

2. Is there a particular container type that will enable me to achieve this?

3. Would I have any more success if I transcoded the frames to a guaranteed particular video and audio codecs?

4. Is there another way to achieve a variable frame rate?


Thanks for your help,

Robert



_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Muxing to file with unknown frame rate

Carl Eugen Hoyos-2
2017-04-12 16:29 GMT+02:00 Robert Jamieson <[hidden email]>:

> I am attempting to mux footage from a variety of webcams into standards
> based files. The footage is spread over a large number of files (all from
> the same camera). The files are a proprietary format containing the encoded
> frames that came directly from the camera (in most cases it is H.264, MJPEG
> or MPEG4 with G.711 or PCM16 audio). Audio is optional.
>
>
> I have created a pipeline for processing the footage that comprises of a
> reader for the files (this reads the frames and pushes them through the
> pipeline), a file sync that picks a suitable file format (based on the
> incoming video and audio formats) and writes the already encoded frames into
> the file. I am purposely not using a transcoder to save processing time.

Just curious:
Why can't you use the FFmpeg executable?

Or to say it differently: Is there an input sample file that is not
supported by FFmpeg?

> This is working well with one exception, I can't tell what the frame rate is
> ahead of time because I can't read the files before I process them.

FFmpeg's mov muxer only supports cfr, so you have to know the
framerate in advance.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Muxing to file with unknown frame rate

Robert Jamieson

>From: Libav-user <[hidden email]> on behalf of Carl Eugen Hoyos <[hidden email]>

>Sent: 12 April 2017 20:46 GMT
>To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.
>Subject: Re: [Libav-user] Muxing to file with unknown frame rate
>

>>2017-04-12 16:29 GMT+02:00 Robert Jamieson <[hidden email]>:

>> I am attempting to mux footage from a variety of webcams into standards

>> based files. The footage is spread over a large number of files (all from
>> the same camera). The files are a proprietary format containing the encoded
>> frames that came directly from the camera (in most cases it is H.264, MJPEG
>> or MPEG4 with G.711 or PCM16 audio). Audio is optional.
>>
>>
>> I have created a pipeline for processing the footage that comprises of a
>> reader for the files (this reads the frames and pushes them through the
>> pipeline), a file sync that picks a suitable file format (based on the
>> incoming video and audio formats) and writes the already encoded frames into
>> the file. I am purposely not using a transcoder to save processing time.
>
>Just curious:
>Why can't you use the FFmpeg executable?
>
>Or to say it differently: Is there an input sample file that is not
>supported by FFmpeg?

The files are in a proprietary format and are both encrypted and contain other data.

I'm also decoding for playback as part of a wider application.

>> This is working well with one exception, I can't tell what the frame rate is
>> ahead of time because I can't read the files before I process them.

>FFmpeg's mov muxer only supports cfr, so you have to know the
>framerate in advance.

I have done some tests and noticed that both VLC and WMP seem to be far more supportive of mp4 containers with vfr and playback without issue.

Ideally I would like to support other containers for flexibility and also allow for not re-encoding the data to increase performance but at the moment it doesn't look like I will be able to do that.

>Carl Eugen


_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Muxing to file with unknown frame rate

강구철
sorry if this client top posts, but to answer, you can do 1 of 2 things.
assume it is different and insert it before returning to the unprocessed
clip. or you can check if they are different by doing a comparison.

 

 

​Thanks for your suggestion. Let's say if original H.264 video stream has
AVCC bitstream, no matter you encode 1st part with Annex-b or AVCC, as long
as it's different from orginal format, I won't be able to do codec copy
using readpacket/writepacket, right?

 

 

From: Libav-user [mailto:[hidden email]] On Behalf Of Robert
Jamieson
Sent: Thursday, April 13, 2017 6:25 AM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice
and libavfilter.
Subject: Re: [Libav-user] Muxing to file with unknown frame rate

 

>From: Libav-user <[hidden email]> on behalf of Carl Eugen
Hoyos <[hidden email]>

>Sent: 12 April 2017 20:46 GMT
>To: This list is about using libavcodec, libavformat, libavutil,
libavdevice and libavfilter.
>Subject: Re: [Libav-user] Muxing to file with unknown frame rate

>

>>2017-04-12 16:29 GMT+02:00 Robert Jamieson <[hidden email]>:

>> I am attempting to mux footage from a variety of webcams into standards

>> based files. The footage is spread over a large number of files (all from
>> the same camera). The files are a proprietary format containing the
encoded
>> frames that came directly from the camera (in most cases it is H.264,
MJPEG
>> or MPEG4 with G.711 or PCM16 audio). Audio is optional.
>>
>>
>> I have created a pipeline for processing the footage that comprises of a
>> reader for the files (this reads the frames and pushes them through the
>> pipeline), a file sync that picks a suitable file format (based on the
>> incoming video and audio formats) and writes the already encoded frames
into
>> the file. I am purposely not using a transcoder to save processing time.
>
>Just curious:
>Why can't you use the FFmpeg executable?

>

>Or to say it differently: Is there an input sample file that is not
>supported by FFmpeg?

The files are in a proprietary format and are both encrypted and contain
other data.

 

I'm also decoding for playback as part of a wider application.

>> This is working well with one exception, I can't tell what the frame rate
is
>> ahead of time because I can't read the files before I process them.

>FFmpeg's mov muxer only supports cfr, so you have to know the
>framerate in advance.

 

I have done some tests and noticed that both VLC and WMP seem to be far more
supportive of mp4 containers with vfr and playback without issue.

 

Ideally I would like to support other containers for flexibility and also
allow for not re-encoding the data to increase performance but at the moment
it doesn't look like I will be able to do that.

>Carl Eugen


_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user

winmail.dat (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

[Libav-user] what is problem ?

강구철
In reply to this post by Robert Jamieson
this is err message.

I use ffmpeg3.2.4. why no define PIX_FMT_RGB24 ?

is this version problem ?? pls help me!!!

 

 

 

gcc -Wall -ggdb tutorial01.c  -c -o obj/tutorial01.o

tutorial01.c: In function ‘main’:

tutorial01.c:84: warning: ‘codec’ is deprecated (declared at
/usr/local/include/libavformat/avformat.h:893)

tutorial01.c:92: warning: ‘codec’ is deprecated (declared at
/usr/local/include/libavformat/avformat.h:893)

tutorial01.c:113: warning: ‘avpicture_get_size’ is deprecated (declared
at /usr/local/include/libavcodec/avcodec.h:5468)

tutorial01.c:113: error: ‘PIX_FMT_RGB24’ undeclared (first use in this
function)

tutorial01.c:113: error: (Each undeclared identifier is reported only once

tutorial01.c:113: error: for each function it appears in.)

tutorial01.c:135: warning: ‘avpicture_fill’ is deprecated (declared at
/usr/local/include/libavcodec/avcodec.h:5453)

tutorial01.c:144: warning: ‘avcodec_decode_video2’ is deprecated
(declared at /usr/local/include/libavcodec/avcodec.h:4812)

tutorial01.c:169: warning: ‘av_free_packet’ is deprecated (declared at
/usr/local/include/libavcodec/avcodec.h:4473)


_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user

winmail.dat (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: what is problem ?

Carl Eugen Hoyos-2
2017-04-13 3:56 GMT+02:00 강구철 <[hidden email]>:
> this is err message.
>
> I use ffmpeg3.2.4. why no define PIX_FMT_RGB24 ?

Because four years ago, it was changed into AV_PIX_FMT_RGB24
to avoid polluting your namespace.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user