Opened 8 years ago

Last modified 7 weeks ago

#2602 open enhancement

Implement a soft-telecine filter

Reported by: microchip Owned by:
Priority: wish Component: avformat
Version: git-master Keywords: mpegps pulldown mpeg2video
Cc: electron.rotoscope, stw392@blue-cable.de Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Hi,

It'd be useful to flag progressive 23.976fps NTSC content as soft-telecined when encoding to DVD. MEncoder already supports this when using -of mpeg format=dvd:tsaf:telecine. Alternatively, if no new filters is desired, this functionality could be added to the existing telecine ffmpeg filter.

Thanks

Attachments (3)

without_pulldown_flag.m2v (371.7 KB ) - added by electron.rotoscope 7 years ago.
original m2v encoded from ffmpeg
with_pulldown_flag.m2v (371.7 KB ) - added by electron.rotoscope 7 years ago.
ffmpeg encode after running through dgpulldown
ffmpeg-telecine.diff (3.6 KB ) - added by MetalThrashingManiac 13 months ago.
Possible telecine implementation inside mpeg2video enc

Download all attachments as: .zip

Change History (20)

comment:1 by Carl Eugen Hoyos, 8 years ago

Please provide a (failing) FFmpeg and the matching (successful) MEncoder command line.

comment:2 by microchip, 8 years ago

Hi

I can't provide a failing ffmpeg command line as ffmpeg doesn't support soft-telecining of content while mencoder does and i already provided the mencoder example in my first post. I'm not sure what you want me to provide. All I ask is the possibility to set a soft-telecine flag when encoding to NTSC DVD, just like it's possible with mencoder ... -of mpeg format=dvd:telecine

comment:3 by Carl Eugen Hoyos, 8 years ago

mencoder ... -of mpeg format=dvd:telecine doesn't look like a command line that could be used for testing once the feature is implemented in FFmpeg.

comment:4 by microchip, 8 years ago

You want me to provide the full mencoder command line to soft-telecine a progressive 23.976fps content? Because I don't know what else to provide.

mencoder input-24p.avi -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=3000 -nosound -of mpeg -mpegopts format=dvd:tsaf:telecine -ofps 24000/1001 -o output.mpg

What the above will do is make the 23.976fps input seem as if it's encoded at 30000/1001. The output is still progressive, but with a soft-telecine flag set so a NTSC DVD player will handle it correctly.

When played back by mplayer, it will correctly recognize the soft-telecine and will print a message about switching frame rate.

That's basically the feature I want supported by ffmpeg's telecine filter (if possible). If not, maybe implement it at the muxer level and add an option to flag it as soft-telecined

comment:5 by llogan, 8 years ago

Summary: Inplement a soft-telecine filterImplement a soft-telecine filter

comment:6 by Carl Eugen Hoyos, 8 years ago

Component: avfilteravformat
Keywords: mpegps pulldown added
Priority: normalwish
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

comment:7 by electron.rotoscope, 7 years ago

The relevant code in mencoder seems to be lines 2468 - 2491 of \libmpdemux\muxer_mpeg.c in today's tarball and they used the code from DGPulldown which is a GPL program. The code in mencoder starts with: /* excerpt from DGPulldown Copyright (C) 2005-2006, Donald Graft */
I think it would be useful to add this feature to all MPEG-2 encoding, not just MPEG-PS, as some authoring programs only take raw .m2v files. I know this is possible, DGPulldown can add the flags after the fact as a separate process.

comment:8 by Carl Eugen Hoyos, 7 years ago

Cc: electron.rotoscope added
Keywords: mpeg2video added

I removed both attachments because their license is not compatible with the relevant files from FFmpeg (LGPL vs GPL). Both can be found easily.
If you are interested in this feature but cannot supply a patch, maybe attach two short m2v samples that show the difference with similar / identical content? Ideally by encoding with FFmpeg and later changing the output file as explained in your post.

by electron.rotoscope, 7 years ago

Attachment: without_pulldown_flag.m2v added

original m2v encoded from ffmpeg

by electron.rotoscope, 7 years ago

Attachment: with_pulldown_flag.m2v added

ffmpeg encode after running through dgpulldown

comment:9 by electron.rotoscope, 7 years ago

Original and modified file now attached as suggested. I've just checked and the file without the flag will not import into a DVD authoring program, the file with the flag will.

I notice that DGPulldown changes what MediaInfo calls "Time code of first frame" from 00:00:00:00 to 00:00:00;00, but as far as I know this is NOT necessary for DVD authoring.

comment:10 by Dave P., 6 years ago

+1 for this enhancement

by MetalThrashingManiac, 13 months ago

Attachment: ffmpeg-telecine.diff added

Possible telecine implementation inside mpeg2video enc

comment:11 by MetalThrashingManiac, 13 months ago

Cc: stw392@blue-cable.de added

This implementation is based on the one in mpeg2enc and the like. It does not affect the encoding process, it just changes some flags in the bitstream, as e.g. DGPulldown does.
Will be activated by -telecine:v 1 private option. Works with 24000/1001 and 24 fps progressive content.

comment:12 by Carl Eugen Hoyos, 13 months ago

Who wrote this patch and under what license was the original code released?

I would have expected that the option is not boolean but a target frame rate.

in reply to:  12 comment:13 by MetalThrashingManiac, 13 months ago

Replying to cehoyos:

Who wrote this patch and under what license was the original code released?

I would have expected that the option is not boolean but a target frame rate.

Patch was written by me; and license should be LGPL v2.1, as stated in the files affected by the patch.

As I wrote, implementation is based on mpeg2enc, hence no arbitrary frame rates.

comment:14 by Balling, 10 months ago

I would have expected that the option is not boolean but a target frame rate.

Why? It supports only 24/1.001 (not even 24.000, though IMHO it can by mistake, that the opposite from Blu-ray that supports both), which is a flag, i.e. boolean. I understand that the Mencoder was cool with all those options back then to reencode, but we do not need it anymore or DVDs for that matter. Also, a ffmpeg does read the flag. So...

Also, see #5662. That is not that simple, you can have multiple cadences on screen at the same time.

comment:16 by Balling, 2 months ago

After DGpulldown mpv recognises the file as being 23.977 which is wrong (actually that was just slow change). Also timecode SMPTE style is changed from ":" to ";".

Last edited 7 weeks ago by Balling (previous) (diff)

comment:17 by Balling, 2 months ago

See sample here https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3968/ and #3968 for more crazy cadence. Also AGAIN -bsf:v mpeg2_metadata=ivtc=1 patch is here!!

Note: See TracTickets for help on using tickets.