Opened 10 months ago

Last modified 9 months ago

#7055 new defect

Using decimate allows EIA-608 captions to pass through to MP4 files even when the -sn option is used

Reported by: navilor Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: decimate cc
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

I am currently using FFmpeg build number N-89980-ge752da5464. This issue also reproduces using build number N-87130-g2b9fd15 which is much older.

I have some MPEG-PS content that is behind NTSC hard telecine. As such I am using both yadif and decimate to remove that. If I use decimate then EIA-608 captions pass through even when the -sn option is in place. If I do not use decimate then captions, as expected, do not pass through because the -sn option is in place.

Note that the size of the data stream reported by MediaInfo? is zero in both the source media as well as the output MP4 file. The data stream plays back as expected in the VOB file but not in the MP4 file.

How to reproduce:

ffmpeg -t 00:01:00 -fpsprobesize 48 -i decimate-allows-EIA-608-captions-to-pass-through-S01E01.vob -vf yadif,decimate,crop=720:480:0:0,scale=720:480 -pix_fmt yuv420p -vsync 1 -sn -map 0:1 -r 23.976 -threads 0 -vcodec libx264 -b:v:0:1 803752 -bufsize 1410194 -maxrate 1004690 -an  -preset medium -profile:v high -g 48 -tune film -x264opts no-scenecut -map_metadata -1 -f mp4 -y S01E01-decimate.mp4-video.mp4

Compare against the following command line that does not use the decimate option:

ffmpeg -t 00:01:00 -fpsprobesize 60 -i decimate-allows-EIA-608-captions-to-pass-through-S01E01.vob -vf yadif,crop=720:480:0:0,scale=720:480 -pix_fmt yuv420p -vsync 1 -sn -map 0:1 -r 29.970 -threads 0 -vcodec libx264 -b:v:0:1 818252 -bufsize 1428319 -maxrate 1022815 -an -preset medium -profile:v high -g 60 -tune film -x264opts no-scenecut -map_metadata -1 -f mp4 -y S01E01.mp4-video.mp4

It is important to either have full subtitles in a file or none at all especially when delivering streaming media compliant content. I always use a sidecar file for my VOD captions.

I am currently attempting to upload a copy of the sample media and the associated text file to ftp://upload.ffmpeg.org per your bug report documentation at https://ffmpeg.org/bugreports.html, however I am unable to connect to upload.ffmpeg.org via either WinSCP's FTP or Windows 7's command line FTP.

The names of the files I plan to upload for replication will be named as following provided I can establish communication with the server.

decimate-allows-EIA-608-captions-to-pass-through-S01E01.vob
decimate-allows-EIA-608-captions-to-pass-through-S01E01.txt

Attachments (1)

S01E01-small.vob (2.4 MB) - added by navilor 10 months ago.
Short sample of content.

Change History (12)

comment:1 Changed 10 months ago by navilor

  • Summary changed from Using decimate allows EIA-608 captions to pass through to MP4 file even when the -sn option is uses to Using decimate allows EIA-608 captions to pass through to MP4 files even when the -sn option is used

comment:2 Changed 10 months ago by navilor

Update.

This behavior also happens if you use pullup.

ffmpeg input.vob -vf pullup,dejudder,yadif=deint=1,crop=720:480:0:0,scale=720:480 -pix_fmt yuv420p -vsync 1 -sn -dn -map 0:1 -threads 0 -vcodec libx264 -r 23.976 -b:v:0:1 695192 -bufsize 1274494 -maxrate 868990 -an -preset medium -profile:v high -g 48 -tune film -x264opts no-scenecut -map_metadata -1 -f mp4 -y output.mp4

When using either decimate or pullup both have subtitles that can be played back via VLC.

comment:3 Changed 10 months ago by cehoyos

  • Component changed from ffmpeg to undetermined
  • Keywords cc added; captions removed
  • Priority changed from minor to normal
  • Version changed from 3.4 to unspecified

To make this a valid ticket, please test current FFmpeg git head, provide the command line you tested together with the complete, uncut console output and upload a short sample. Either use https://streams.videolan.org/upload/ or a filehoster of your choice.
And please simplify your command line: The -r option is wrong, others should be unneeded.

comment:4 Changed 10 months ago by navilor

Updated FFmpeg to version N-90173-gfa0c9d69d3 from Zerano's website.

https://ffmpeg.zeranoe.com/builds/

Track persists and plays in VLC.

decimate:

./zffmpeg.exe -i S01E01.vob -vf yadif,decimate,dejudder,crop=720:480:0:0,scale=720:480 -pix_fmt yuv420p -vsync 1 -sn -dn -map 0:1 -threads 0 -vcodec libx264 -r 23.976 -crf 23 -acodec aac -map 0:2 -b:a:0:2 405504 -ac 2 -ar 48000 -af aresample=async=1:min_hard_comp=0.100000:first_pts=0 -preset veryfast -profile:v baseline -g 48 -tune film -x264opts no-scenecut -map_metadata -1 -f mp4 -y S01E01-decimate.mp4

pullup:

./zffmpeg.exe -i S01E01.vob -vf pullup,dejudder,yadif=deint=1,crop=720:480:0:0,scale=720:480 -pix_fmt yuv420p -vsync 1 -sn -dn -map 0:1 -threads 0 -vcodec libx264 -r 23.976 -crf 23 -acodec aac -map 0:2 -b:a:0:2 405504 -ac 2 -ar 48000 -af aresample=async=1:min_hard_comp=0.100000:first_pts=0 -preset veryfast -profile:v baseline -g 48 -tune film -x264opts no-scenecut -map_metadata -1 -f mp4 -y S01E01-pullup.mp4

Changed 10 months ago by navilor

Short sample of content.

comment:5 Changed 10 months ago by navilor

This is the command line I just ran to replicate the problem.

./zffmpeg.exe -v 9 -loglevel 99 -i S01E01-small.vob -sn -dn -vf yadif,decimate,dejudder,crop=720:480:0:0,scale=720:480 -pix_fmt yuv420p -vsync 1 -map 0:1 -threads 0 -vcodec libx264 -r 23.976 -b:v:0:1 688365 -bufsize 1265960 -maxrate 860456 -minrate 550692 -an -pass 1 -preset medium -profile:v high -g 48 -tune film -x264opts no-scenecut -map_metadata -1 -f mp4 -y f:zcygout/S01E01-decimate.mp4 &> 7055.log

I have just uploaded a zip file called Ticket 7055-001.zip that contains all of the following:

1) S01E01-small.vob which is the source file.

2) S01E01-decimate.mp4 which is the output file.

3) The console out log file called 7055.log.

4) The ffmpeg2pass-0.log file.

5) The ffmpeg2pass-0.log.mbtree file.

comment:6 Changed 10 months ago by navilor

Note that the following warning does not happen when I use the full file:

[mpeg2video @ 00000000004fb480] ac-tex damaged at 14 22
[mpeg2video @ 00000000004fb480] Warning MVs not available
[mpeg2video @ 00000000004fb480] concealing 360 DC, 360 AC, 360 MV errors in P frame

comment:7 Changed 9 months ago by navilor

I have uploaded the file "decimate-allows-EIA-608-captions-to-pass-through-S01E01.vob" via the upload page you provided. I now have additional information and moved the -r option to before the video codec.

When I run the following command line using CRF captions do not come through.

ffmpeg -t 00:05:00 -i decimate-allows-EIA-608-captions-to-pass-through-S01E01.vob -vf yadif,decimate,dejudder -pix_fmt yuv420p -vsync 1 -threads 0 -r 23.976 -sn -vcodec libx264 -g 48 -crf 23 -preset veryfast -profile:v baseline -tune film -x264opts no-scenecut -an -map_metadata -1 -f mp4 -y S01E01-script001.mp4-video.mp4

When I run the exact same command except I encode to bitrate captions pass through for both single and two pass encoding.

ffmpeg -t 00:05:00 -i decimate-allows-EIA-608-captions-to-pass-through-S01E01.vob -vf yadif,decimate,dejudder -pix_fmt yuv420p -vsync 1 -threads 0 -r 23.976 -sn -vcodec libx264 -g 48 -b:v 808385 -bufsize 1415985 -maxrate 1010481 -preset medium -profile:v high -tune film -x264opts no-scenecut -an -map_metadata -1 -f mp4 -y S01E01-script001.mp4-video.mp4

comment:8 in reply to: ↑ description Changed 9 months ago by cehoyos

Replying to navilor:

I have some MPEG-PS content that is behind NTSC hard telecine. As such I am using both yadif and decimate to remove that.

Why? Do you believe it is a good idea to use a de-interlacer for the inverse telecine process? (It usually is not a good idea because it permanently damages your video while the inverse telecine process should be lossless.)
You may or may not have found a bug but using a command line that never makes sense makes me wonder if there really is an issue.

And please simplify your command line: The -r option is wrong, others should be unneeded.

Sorry for being unclear: If -r is needed (it should not but this likely an effect of using decimate incorrectly), the correct syntax would be -r 24000/1001.
Please try to simplify the command line and please provide command line including complete, uncut console output to make this a valid ticket.

comment:9 Changed 9 months ago by navilor

Why? Do you believe it is a good idea to use a de-interlacer for the inverse telecine process? (It usually is not a good idea because it permanently damages your video while the inverse telecine process should be lossless.)

The output of the file can have some interlacing artifacts. The same thing happens with pullup. I added yadif only after I found interlacing artifacts in the output file.

Sorry for being unclear: If -r is needed (it should not but this likely an effect of using decimate incorrectly), the correct syntax would be -r 24000/1001.

Please try to simplify the command line and please provide command line including complete, uncut console output to make this a valid ticket.

Thank you for the clarification. I will update my script accordingly

I have been in the streaming media industry for ten years. The reason the command line structure is like that is that streaming media requires a few things.

1) Constant frame rate.
2) A perfect GOP.
3) A bitrate based encode.

Things that are nice to have are.
4) Finding a better bitrate for your content.
5) Hitting your target bitrate.
6) Audio encoding without A/V drift.
7) Proper encoding for your target audiences.

In the end my content has perfect PTS/DTS time stamps, an exact GOP, the audio and video do not drift, and the bitrate is precise based off of a CRF 23 encode where the "bitrate" is extracted via FFprobe for two pass average bitrate encoding.

I detail the reasoning for my command line structure in my personal blog. Effectively I cannot trust that the content that is provided to me is clean and will convert nicely. One of my posts on my blog is featured in an article by Jan Ozer. It is also referenced in his book Video Encoding by the Numbers in Chapter 7: Choosing Data Rate.

https://videoblerg.wordpress.com/2017/11/10/ffmpeg-and-how-to-use-it-wrong/

I have, over time, created a 1,600 line heavily documented bash shell script that analyzes incoming content and creates a command line that will compensate for most forms of bad content.

I will work on simplifying the command line and hope to have a reply with one soon.

comment:10 Changed 9 months ago by tmm1

I'm not sure why decimate changes behavior, but caption data is embedded in mpeg2 user data and is not considered a subtitle by ffmpeg. You can control whether or not the libx264 encoder includes the caption data in the output video using the -a53cc option. There is also a patch on the list I submitted a couple days ago for a mpeg2_metadata_bsf option to remove a53 data from the mpeg2 bitstream.

comment:11 Changed 9 months ago by navilor

Thank you very much for providing me information on the -a53cc option. It is working as expected. What baffles me entirely is that the -ac option removes EIA-608 captions when I do not use decimate. I have been using that option for years.

Will the mpeg2_metadata_bsf option work with both MPEG Video Version 2 and H.264 content in an MPEG-TS container, specifically the m2ts container? I ask because I am hoping that it will be a codec neutral option.

Note: See TracTickets for help on using tickets.