<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>I am glad someone finally answered this as I complained about
this long time ago, with no answer.<br>
</p>
<br>
<div class="moz-cite-prefix">El 05/11/19 a las 09:36, Vassilis
escribió:<br>
</div>
<blockquote
cite="mid:CAGcmhj7gLYmnS-GABxEnmjbSx-FsxHDWq2oshUw0jwaNmE8fWw@mail.gmail.com"
type="cite">
<div dir="ltr">Well that did the trick! I can't thank you enough
James and also second your comment that this should be updated
in the transcoding.c example.
<div>Is there anything we can do about this?</div>
<br>
</div>
</blockquote>
I still cannot get it to work. I get a floating point exception
with the division of this in my code:<br>
<br>
stream->avg_frame_rate.num * stream->avg_frame_rate.den;<br>
<br>
Where are you guys setting the avg_frame_rate? The transcoding.c
example never sets it.<br>
<br>
<blockquote
cite="mid:CAGcmhj7gLYmnS-GABxEnmjbSx-FsxHDWq2oshUw0jwaNmE8fWw@mail.gmail.com"
type="cite"><br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Nov 5, 2019 at 2:03 PM
James Crisafulli <<a moz-do-not-send="true"
href="mailto:james2048@gmail.com">james2048@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<div>Hi,</div>
<div><br>
</div>
<div>I used to have the same issue with my application,
which I based on transcoding.c (not transcoding but
anyways, writing H264 to MP4 file).</div>
<div>You need to set the AVPacket duration field, for some
reason it shows this issue if you let it automatically
set it (set to -1).</div>
<div>I had to do this both using libx264 and mpeg4
encoders.</div>
<div><br>
</div>
<div>Example in my code from the muxing section:</div>
<div><br>
</div>
<div>av_packet_rescale_ts(&packet,
codecCtx->time_base, stream->time_base);<br>
packet.stream_index = 0;</div>
<div>// probably best to write this as av_rescale_*
functions, but this is old code</div>
<div>// for example, if 25 FPS, and time_base is 12800,
then packet.duration = 12800 / 25 = 512<br>
packet.duration = stream->time_base.den /
stream->time_base.num / stream->avg_frame_rate.num
* stream->avg_frame_rate.den;<br>
// now you can mux<br>
ret = av_interleaved_write_frame(formatCtx,
&packet);<br>
</div>
<div><br>
</div>
<div>I am not sure why this is needed, I found this in
another codebase with a similar comment, and it fixed my
issue.</div>
<div><br>
</div>
<div>Might as well mention that in transcoding.c, it also
doesn't set the GLOBAL_HEADER flag at the right time,
and as such you get a malformed file if writing MP4
format. I noticed it wouldn't open in Adobe Premiere,
and Windows 10 Films & TV player, and ffprobe had
warnings about it as well but did manage to read it.</div>
<div><br>
</div>
<div>// TOO LATE! has to be done before avcodec open!! In
transcoding.c, it does this after the call and as such
the flags are ignored.<br>
</div>
<div>if (formatCtx->oformat->flags &
AVFMT_GLOBALHEADER)<br>
{<br>
codecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;<br>
}<br>
</div>
<div><br>
</div>
<div>To fix that, I have hard coded the flag early when I
know I am writing MP4, before avcodec_open():</div>
<div><br>
</div>
<div>codecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;<br>
AVDictionary *encoderOpts = nullptr;<br>
ret = avcodec_open2(codecCtx, codecCtx->codec,
&encoderOpts);<br>
</div>
<div><br>
</div>
<div>And now everything works well for me. Hopefully it
fixed the issues for you as well.</div>
<div>Would be nice to see transcoding.c updated to fix
these small issues as it is used as a base by so many
people looking into libav* development.</div>
<div><br>
</div>
<div>- James </div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, 5 Nov 2019 at
11:07, Vassilis <<a moz-do-not-send="true"
href="mailto:bpantazhs@gmail.com" target="_blank">bpantazhs@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">This can not be reproduced with the ffmpeg
cli, conversion works fine there.
<div>However it can be reproduced with transcoding.c for
all input files.</div>
<div>Additionally to what I mentioned, 29.96 fps test
files result in 29.98 and 30 to 30.11.</div>
<div>Another 24 fps file resulted in 24.03. The changes
seem to be related with </div>
<div>the duration of the file: the longer the file the
shorter the marginal fps difference. </div>
<div>The output frame rate can be determined with both
fffmpeg -i as well as with</div>
<div>QuickTime 7 and VLC. Like I mentioned, I have spent
some time with investigating this</div>
<div>and it looks like an issue with the correct
conversion of the last frame; I was able</div>
<div>to get different framerate values when tampering
with the pts of the last frame</div>
<div>but this looked like a nasty hack that I shouldn't
be doing, plus it fails</div>
<div>again when re-encoding the file. Here is the info
from an input/output test file</div>
<div>that has the frame rate changed from 24 fps to
24.03:</div>
<div><br>
</div>
<div> Duration: 00:00:36.08, start: 0.000000, bitrate:
178309 kb/s<br>
Stream #0:0(eng): Video: dnxhd (DNXHD) (AVdn /
0x6E645641), yuv422p10le(tv, bt709/unknown/unknown),
1920x1080, 176160 kb/s, SAR 1:1 DAR 16:9, 24 fps, 24
tbr, 23976 tbn, 23976 tbc (default)</div>
<div><br>
</div>
<div> Duration: 00:00:36.10, start: 0.000000, bitrate:
116072 kb/s<br>
Stream #0:0: Video: dnxhd (DNXHD) (AVdn /
0x6E645641), yuv422p(tv, bt709/unknown/unknown),
1920x1080, 116526 kb/s, SAR 1:1 DAR 16:9, 24.03 fps,
24 tbr, 12288 tbn, 12288 tbc (default)<br>
</div>
<div><br>
</div>
<div>You'll notice that there is a slight change in the
duration as well, but this happens with the ffmpeg
conversion with the cli as well.</div>
<div><br>
</div>
<div>Let me know if you need more information and thanks
for the help!</div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Nov 5, 2019 at
3:42 AM Carl Eugen Hoyos <<a moz-do-not-send="true"
href="mailto:ceffmpeg@gmail.com" target="_blank">ceffmpeg@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px
0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">Am Di., 5. Nov.
2019 um 00:16 Uhr schrieb Vassilis <<a
moz-do-not-send="true"
href="mailto:bpantazhs@gmail.com" target="_blank">bpantazhs@gmail.com</a>>:<br>
> I am trying simply to perform a transcoding
process using the transcoding.c example from
doc/examples. However I am seeing a very strange
result (even when the example is not modified at all,
ie not even changing codecs); the transcoded file has
a marginally different frame rate than the original
file. For example for a frame rate of 24 fps I get
24.14 fps. I also implemented this with the newer
av_send/receive packet/frame functions to no avail. I
would be most grateful for any insights, I've spent
quite some time trying to troubleshoot this.<br>
<br>
Can you reproduce the issue with the ffmpeg cli or
only with transcoding.c?<br>
<br>
Why do you think that the output frame rate is 24.14?
What does ffmpeg<br>
-i show for your input file?<br>
<br>
Carl Eugen<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a moz-do-not-send="true"
href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a moz-do-not-send="true"
href="https://ffmpeg.org/mailman/listinfo/libav-user"
rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a moz-do-not-send="true"
href="mailto:libav-user-request@ffmpeg.org"
target="_blank">libav-user-request@ffmpeg.org</a>
with subject "unsubscribe".</blockquote>
</div>
_______________________________________________<br>
Libav-user mailing list<br>
<a moz-do-not-send="true"
href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a moz-do-not-send="true"
href="https://ffmpeg.org/mailman/listinfo/libav-user"
rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a moz-do-not-send="true"
href="mailto:libav-user-request@ffmpeg.org"
target="_blank">libav-user-request@ffmpeg.org</a> with
subject "unsubscribe".</blockquote>
</div>
_______________________________________________<br>
Libav-user mailing list<br>
<a moz-do-not-send="true" href="mailto:Libav-user@ffmpeg.org"
target="_blank">Libav-user@ffmpeg.org</a><br>
<a moz-do-not-send="true"
href="https://ffmpeg.org/mailman/listinfo/libav-user"
rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a moz-do-not-send="true"
href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a>
with subject "unsubscribe".</blockquote>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Libav-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a>
<a class="moz-txt-link-freetext" href="https://ffmpeg.org/mailman/listinfo/libav-user">https://ffmpeg.org/mailman/listinfo/libav-user</a>
To unsubscribe, visit link above, or email
<a class="moz-txt-link-abbreviated" href="mailto:libav-user-request@ffmpeg.org">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</pre>
</blockquote>
<br>
</body>
</html>