Re: [FFmpeg-user] Retain but don't playback frames outside of edit list for transcode

2024-05-07 Thread Gyan Doshi



On 2024-05-08 08:55 am, Anne Wu via ffmpeg-user wrote:

Hi,
Looking for some guidance on if handling edit-lists this way is
possible. I recently ran into a situation where I need to transcode
videos that include edit lists. The edit-list specifies to drop the
first few frames of the video, and thus the output ends up with fewer
frames than the original. Is there a way to retain these frames in
the output, but not have them play during playback? I’m looking for
the number of frames in the input and output file to be the same.

The original video has 386 frames. This is the transcode command that
outputs a file with 376 frames: ffmpeg -i ./original.mov -c:v
libx264 -fps_mode passthrough output.mov

If I use the -ignore_editlist 1 option, it will retain the frames
outside the edit-list and end up with 386 frames. But it still plays
back all the frames, which is not the desired behavior:
ffmpeg -ignore_editlist 1 -i ./original.mov -c:v libx264 -fps_mode
passthrough output_ignoreEditList.mov


This may work:
Get the timestamp of the first displayed frame.
Then do a transcode of all frames with ignore editlist,
Use the setts bsf on the video stream to offset timestamps so that the 
first displayed frame has a dts of 0.


Regards,
Gyan

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-user] Retain but don't playback frames outside of edit list for transcode

2024-05-07 Thread Anne Wu via ffmpeg-user
Hi,
Looking for some guidance on if handling edit-lists this way is
possible. I recently ran into a situation where I need to transcode
videos that include edit lists. The edit-list specifies to drop the
first few frames of the video, and thus the output ends up with fewer
frames than the original. Is there a way to retain these frames in
the output, but not have them play during playback? I’m looking for
the number of frames in the input and output file to be the same.

The original video has 386 frames. This is the transcode command that
outputs a file with 376 frames: ffmpeg -i ./original.mov -c:v
libx264 -fps_mode passthrough output.mov

If I use the -ignore_editlist 1 option, it will retain the frames
outside the edit-list and end up with 386 frames. But it still plays
back all the frames, which is not the desired behavior:
ffmpeg -ignore_editlist 1 -i ./original.mov -c:v libx264 -fps_mode
passthrough output_ignoreEditList.mov

Using -c:v copy instead of transcode works, but I need to do a
transcode and not a copy.

The original, transcoded, and transcoded with -ignore_editlist 1
files are available here.
Thanks!
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-user] Why cuts & concats sometimes don't work

2024-05-07 Thread Mark Filipak

Hi All,

I'm still investigating why cuts & concats sometimes don't work. I've found that sometimes open GOPs 
are physically in PTS order & sometimes in DTS order. I reckon that's part/all of the problem.


I have some questions.

Command #1:
ffmpeg -i y:\VIDEO_TS\VTS_03_2.VOB -map 0 -copyts -c copy -f framecrc 
->>"%TEMP%\framecrc.txt"

Command #2:
ffmpeg -i y:\VIDEO_TS\VTS_03_2.VOB -map 0:v -copyts -vf showinfo -c:v rawvideo -f null - 
2>>"%TEMP%\showinfo.txt"


= OUTPUT FOR THE FIRST FOUR FRAMES =

   packet_dts  packet_pts   packet_duration
  /   // packet_size
 /   // / __0xCRC___ //_(actual)_
#1: 126110985,  126118492,   4504, 77348, 0x3748adeb // 38 packs
126115489,  126115489,   3003, 18060, 0x6843df67 //  9 packs
126118492, -9223372036854775808, 4504, 37184, 0xc96165d5 // 18 packs
126122996,  126122996,   3003, 19440, 0x2b57fd37 // 10 packs

#2: n: 0  pts: 126118492  duration: 4504  type:I
n: 1  pts: 126122996  duration: 3003  type:B
n: 2  pts: 126125999  duration: 4504  type:P
n: 3  pts: 126130503  duration: 3003  type:B

= QUESTIONS =

The PTSes of #1 & #2 don't match. Why is that?

In #1, 'duration' is the duration of what? There are 3003 ticks per frame,
so where does a number like 4504 come from?

#1 & https://ffmpeg.org/ffmpeg-all.html#framecrc-1 claims there are 4
packets but there's actually 75, so what is meant by the word "packet"?

And the biggest question of all: DTSes & PTSes only exist in MPEG PESes
for I-frames. So, where/how is FFmpeg getting TSes for B- & P-frames?

= END NOTES =

Physically, there is the end of a P followed by B P B P B B, then I B P B
 / / / /
frame type: I _PTS 126118492__DTS 126110985_/ / / /
 / / /
frame type: B __/ / /
 / /
frame type: P __/ /
 /
frame type: B __/

FFmpeg reports only the I B P B and the frames that follow them.

--Mark.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-user] A53 Captions Garbled If Frame Duplication Occurs

2024-05-07 Thread Dennis Mungai
On Tue, 7 May 2024 at 18:21, Devin Heitmueller <
devin.heitmuel...@ltnglobal.com> wrote:

> Hi Shane,
>
> On Fri, May 3, 2024 at 5:48 PM Shane Warren  wrote:
> >
> > I ingest some multicast video that has a53 captions embedded in h264
> video, the video claims to have a framerate of 29.97 but it must not quite
> be that because ffmpeg duplicates frames when transcoding this stream. The
> output stream has a53 captions, but they appear to be somewhat garbled,
> like some letters are duplicated, sometimes.
> >
> > I decided to git bisect since I knew this worked in a much older ffmpeg
> binary I had. I finally found the commit that broke this:
> >
> > a11ab647304307d0340fd052e04cf638b6bef309 : fftools/ffmpeg: share the
> code encoding a single frame between video and audio
> >
> > Call do_video_stats() for every video packet produced by the encoder,
> > rather than for every frame sent to the encoder.
> >
> > 
> >
> > The key part that was missed in this commit was calling this directly
> after avcodec_send_frame:
> >
> > // Make sure Closed Captions will not be duplicated
> > av_frame_remove_side_data(in_picture, AV_FRAME_DATA_A53_CC);
> >
> > I fixed this in that commit, and captions worked again. I tried to fix
> it the same way in a the current ffmpeg source by changing:
> >
> > ffmpeg_enc.c encode_frame:
> >
> > ret = avcodec_send_frame(enc, frame);
> > if (ret < 0 && !(ret == AVERROR_EOF && !frame)) {
> > av_log(ost, AV_LOG_ERROR, "Error submitting %s frame to the
> encoder\n",
> >type_desc);
> > return ret;
> > }
> >
> > +if (frame != NULL)
> > +{
> > +   av_frame_remove_side_data(frame, AV_FRAME_DATA_A53_CC);
> > +}
> >
> > But that didn't fix the problem, I suspect this is needed when a frame
> is duplicated, but I can't figure out the place to put that.
> >
> > Anyone have any ideas what I need to change to get captions working in
> the current ffmpeg source?
> > ___
> > ffmpeg-user mailing list
> > ffmpeg-user@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
>
> This was discussed last May in the following thread:
>
> https://ffmpeg.org/pipermail/ffmpeg-devel/2023-June/310534.html
>
> The easiest thing for you to do is use the "fps" filter (i.e. -vf
> fps=6/1001) rather than using "-r".  That makes use of the ccfifo
> framework to ensure that the data is properly preserved.  The hack to
> do it with "-r" actually doesn't work correctly in a number of cases
> (e.g. reducing the framerate), and in fact even with upconverting to
> 59.94 the data doesn't actually conform to the spec, although it works
> in some decoders (specifically you should have every frame with a
> cc_count of 10, when in fact you have it alternating between 20 and
> being absent).
>
> Devin
>
> --
> Devin Heitmueller, Senior Software Engineer
> LTN Global Communications
> o: +1 (301) 363-1001
> w: https://ltnglobal.com  e: devin.heitmuel...@ltnglobal.com
>

Interesting.

Last time I tried to use the fps filter(s) with NVENC and OneVPL, both of
these platforms misbehaved.
For some reason, both seem to require a hint to the "frame length/duration"
, and omitting -r here and switching to the fps filter with these two
implementations wrecks rate-control.
The only work-around to this in FFmpeg with either NVENC or QSV/OneVPL is
tapping into libplacebo OR qsv_vpp filters respectively.
I'm not sure how these two filters handle A53CC emission with frame-rate
upconversion. Will definitely re-test over the course of the week.

BR,

Dennis.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-user] A53 Captions Garbled If Frame Duplication Occurs

2024-05-07 Thread Devin Heitmueller
Hi Shane,

On Fri, May 3, 2024 at 5:48 PM Shane Warren  wrote:
>
> I ingest some multicast video that has a53 captions embedded in h264 video, 
> the video claims to have a framerate of 29.97 but it must not quite be that 
> because ffmpeg duplicates frames when transcoding this stream. The output 
> stream has a53 captions, but they appear to be somewhat garbled, like some 
> letters are duplicated, sometimes.
>
> I decided to git bisect since I knew this worked in a much older ffmpeg 
> binary I had. I finally found the commit that broke this:
>
> a11ab647304307d0340fd052e04cf638b6bef309 : fftools/ffmpeg: share the code 
> encoding a single frame between video and audio
>
> Call do_video_stats() for every video packet produced by the encoder,
> rather than for every frame sent to the encoder.
>
> 
>
> The key part that was missed in this commit was calling this directly after 
> avcodec_send_frame:
>
> // Make sure Closed Captions will not be duplicated
> av_frame_remove_side_data(in_picture, AV_FRAME_DATA_A53_CC);
>
> I fixed this in that commit, and captions worked again. I tried to fix it the 
> same way in a the current ffmpeg source by changing:
>
> ffmpeg_enc.c encode_frame:
>
> ret = avcodec_send_frame(enc, frame);
> if (ret < 0 && !(ret == AVERROR_EOF && !frame)) {
> av_log(ost, AV_LOG_ERROR, "Error submitting %s frame to the 
> encoder\n",
>type_desc);
> return ret;
> }
>
> +if (frame != NULL)
> +{
> +   av_frame_remove_side_data(frame, AV_FRAME_DATA_A53_CC);
> +}
>
> But that didn't fix the problem, I suspect this is needed when a frame is 
> duplicated, but I can't figure out the place to put that.
>
> Anyone have any ideas what I need to change to get captions working in the 
> current ffmpeg source?
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

This was discussed last May in the following thread:

https://ffmpeg.org/pipermail/ffmpeg-devel/2023-June/310534.html

The easiest thing for you to do is use the "fps" filter (i.e. -vf
fps=6/1001) rather than using "-r".  That makes use of the ccfifo
framework to ensure that the data is properly preserved.  The hack to
do it with "-r" actually doesn't work correctly in a number of cases
(e.g. reducing the framerate), and in fact even with upconverting to
59.94 the data doesn't actually conform to the spec, although it works
in some decoders (specifically you should have every frame with a
cc_count of 10, when in fact you have it alternating between 20 and
being absent).

Devin

-- 
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com  e: devin.heitmuel...@ltnglobal.com
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".