FFMPEG dynamic FrameRate Parameter with -c copy option

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

FFMPEG dynamic FrameRate Parameter with -c copy option

Axit Soni
Hi Team,

I am converting my H264 data into MP4 file using -c copy option without
re-encoding.

"*ffmpeg -i <H264_input_fifo> -c copy temp.mp4*"

I don't know on which FrameRate my input "H264_input_fifo" is giving me data
means its varying based on some different condition over different time
period.

If I don't provide "-r" parameter with temp.mp4, it will generate temp.mp4
with 25 fps.
If I provide "-r 30" parameter with temp.mp4, it will generate temp.mp4 with
30 fps.

Is there a way by which I can generate temp.mp4 file with Same FrameRate as
my input H264_input_fifo with Dynamic Input FrameRate Parameter. For
Example, if for 10 seconds my input has 30 fps than output should also have
30 fps... On 11th Seconds on wards if my input has 22 fps than output should
also have 22 fps.

Let me know in case I am not clear.

PS: I don't want to re-encoding with any video filter (-vf)

Thanks.  



--
Sent from: http://www.ffmpeg-archive.org/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: FFMPEG dynamic FrameRate Parameter with -c copy option

Carl Eugen Hoyos-2
2018-09-07 7:36 GMT+02:00, Axit Soni <[hidden email]>:

> I am converting my H264 data into MP4 file using -c copy option without
> re-encoding.
>
> "*ffmpeg -i <H264_input_fifo> -c copy temp.mp4*"
>
> I don't know on which FrameRate my input "H264_input_fifo" is giving me data
> means its varying based on some different condition over different time
> period.
>
> If I don't provide "-r" parameter with temp.mp4, it will generate temp.mp4
> with 25 fps.
> If I provide "-r 30" parameter with temp.mp4, it will generate temp.mp4 with
> 30 fps.

Yes, this is - if it works, the input parameter -r is a bit of a hack and
fails for some usecases - the expected behaviour.

> Is there a way by which I can generate temp.mp4 file with Same FrameRate as
> my input H264_input_fifo with Dynamic Input FrameRate Parameter. For
> Example, if for 10 seconds my input has 30 fps than output should also have
> 30 fps... On 11th Seconds on wards if my input has 22 fps than output should
> also have 22 fps.

Please explain where the input file comes from:
Variable frame rate raw H.264 seems strange to me and I am not sure
if there is any possibility of reading this input correctly. The "real" input,
whatever it is, should provide usable timestamps.

This is apart from the fact that FFmpeg is not good at writing
variable frame rate mp4 files (and this is not recommended), you
could use another container, mkv comes to mind.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Timestamp for variable frame rate (VFR ) video

Wolfgang Hugemann
I have a WhatsApp video which is definitively VFR, as can be told from
the content (a passenger car at constant speed) and is reported by the
new vfrdet filter.

I would like to display a timecode in each frame, derived from the frame
metadata:

"drawtext=text=%%{pts}"
yields wrong results, as it not much more than a frame counter, I guess.

So it should probably be something like

"drawtext=%%{metadata\\:???}

but what exactly?

Wolfgang Hugemann

ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.1 (GCC) 20180722
  configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv
--enable-libass --enable-libbluray --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus
--enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora
--enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg
--enable-lzma --enable-zlib --enable-gmp --enable-libvidstab
--enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa
--enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx
--enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va
--enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Paul B Mahol
On 9/17/18, Wolfgang Hugemann <[hidden email]> wrote:

> I have a WhatsApp video which is definitively VFR, as can be told from
> the content (a passenger car at constant speed) and is reported by the
> new vfrdet filter.
>
> I would like to display a timecode in each frame, derived from the frame
> metadata:
>
> "drawtext=text=%%{pts}"
> yields wrong results, as it not much more than a frame counter, I guess.
>
> So it should probably be something like
>
> "drawtext=%%{metadata\\:???}
>
> but what exactly?

vfrdet filtere uses frame pts. You want timecode and not pts, look at
drawtext manual.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Wolfgang Hugemann
> You want timecode and not pts, look at
> drawtext manual.

You may assume that I already did that.

IMHO, the main issue is not drawtext, but where to get the text from.
There only a few ready-made options, all other information has to be
drawn from metadata provided by some other source.

For example, if you want to print the SMPTE derived from VITC, you use
something like:

-vf "readvitc:drawtext=text=%%{metadata\\:lavfi.readvitc.tc_str}"

Thus if you want to write a timecode / timestamp on the video, you will
probably have to use a certain filer that can provide this information.

Any ideas?

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Paul B Mahol
On 9/17/18, Wolfgang Hugemann <[hidden email]> wrote:

>> You want timecode and not pts, look at
>> drawtext manual.
>
> You may assume that I already did that.
>
> IMHO, the main issue is not drawtext, but where to get the text from.
> There only a few ready-made options, all other information has to be
> drawn from metadata provided by some other source.
>
> For example, if you want to print the SMPTE derived from VITC, you use
> something like:
>
> -vf "readvitc:drawtext=text=%%{metadata\\:lavfi.readvitc.tc_str}"
>
> Thus if you want to write a timecode / timestamp on the video, you will
> probably have to use a certain filer that can provide this information.
>
> Any ideas?

Drawtext filter already have timecode you want, and its in all in documentation.

If you really want timecode and not something else.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Wolfgang Hugemann
> Drawtext filter already have timecode you want, and its in all in
documentation.

Yes, there is a timecode option for the drawtext command, creating a
SMPTE, but using it you have to supply an fixed framerate, which is then
used to produce the SMPTE. This is not the right aprpoach for VFR video.

I consciously used the word timestamp in the subject heading. As there
seems to be confusion about the terminology:

I would like to display the exact time where the frame has to be placed
in the timeline, such that I can calculate the speed of the passenger
car, which ran into an accident.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Gyan Doshi
On Tue, Sep 18, 2018 at 2:35 PM Wolfgang Hugemann <[hidden email]> wrote:

>
>
> I would like to display the exact time where the frame has to be placed
> in the timeline, such that I can calculate the speed of the passenger
> car, which ran into an accident.
>

If the input file has the correct timestamps, then the pts function is what
you need - it is not a "frame counter". You can format the output like
shown at https://video.stackexchange.com/a/21907/1871

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Carl Eugen Hoyos-2
In reply to this post by Wolfgang Hugemann
2018-09-17 15:19 GMT+02:00, Wolfgang Hugemann <[hidden email]>:

> ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers

(Apart from testing current FFmpeg)
Please provide ffmpeg -i output for the stream you want to
analyze.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Timestamp for variable frame rate (VFR ) video

Wolfgang Hugemann
In reply to this post by Gyan Doshi
> If the input file has the correct timestamps, then the pts function is what
> you need - it is not a "frame counter". You can format the output like
> shown at https://video.stackexchange.com/a/21907/1871

This had been my original approach, see my first e-mail. But the time
displayed (blended in) then strictly corresponded to CFR, although the
vfrdet filter (and the observation of the video itself) proofed differently.

(Same thing with ffprobe and best_effort_timestamp_time.)

Perhaps I shoulf first generate a VBR test video with known framerates ...

How could I possibly concatenate two videos with different framerate
into one with VFR? I tried

ffmpeg -y -vsync 2 -i "concat:25.avi|50.avi" test.mp4

with different values for vsync, but it seems that the first input video
settles the (constant) framerate of the output, i.e. 25 fps in the above
example.

Any ideas?

Wolfgang Hugemann



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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Carl Eugen Hoyos-2
2018-09-18 18:34 GMT+02:00, Wolfgang Hugemann <[hidden email]>:

> ffmpeg -y -vsync 2 -i "concat:25.avi|50.avi" test.mp4

This produces an invalid file as FFmpeg does not create
fully compliant vfr mp4 files (that is at least what Baptiste,
the author of the relevant code, claims).

Please tell us more about the properties of your actual
input file to give us a chance to help you.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Wolfgang Hugemann
> Please tell us more about the properties of your actual
> input file to give us a chance to help you.

I would supply it by link, but I can't: It shows a video taken by a
surveillance camera prior to a vehicular accident, and I am obliged to
keep it secret.

It shows the video running on a computer screen, filmed by a mobile
phone camera and then transferred via WhatsApp. These people have ideas ...

Nevertheless, I have just read that most mobile phone cameras record VFR
video and I have just proven that to be correct for my mobile phone
camera. I will produce some demo videos, showing a turntable or alike
(i.e. something moving or turning at constant speed), which will let me
allow to check how correctly ffmpeg deals with VFR video.

These videos can then be easily provided, if necessary. I will inform
you about the results.

Thanks for your help so far!
Wolfgang Hugemann
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp for variable frame rate (VFR ) video

Carl Eugen Hoyos-2
2018-09-18 22:25 GMT+02:00, Wolfgang Hugemann <[hidden email]>:
>> Please tell us more about the properties of your actual
>> input file to give us a chance to help you.
>
> I would supply it by link, but I can't: It shows a video taken by a
> surveillance camera prior to a vehicular accident, and I am obliged to
> keep it secret.

What I asked for was ffmpeg -i output for the file.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".