mltframework / shotcut

cross-platform (Qt), open-source (GPLv3) video editor
https://www.shotcut.org
GNU General Public License v3.0
10.8k stars 1.12k forks source link

Deinterlacing changed framerate unexpected #1425

Closed DarkiStar closed 1 year ago

DarkiStar commented 1 year ago

System used: Windows 10 - 16 GByte RAM - GTX 1060 6 GByte Shotcut version 22.12.21

When I open an interlaced video file from my old Sanyo camera it shows a framerate of 59.940060 fps.

Screenshot1

After converting with following settings:

Screenshot2

and opening the new file, it shows a framerate of 119.880165 fps.

Screenshot3

The deinterlacing worked perfectly (its progressive and looks good), but the framerate change was unexpected for me. When I set the framerate in the convert dialog to the 59 fps (like the source) than the deinterlaced video has the 59 fps setting and everything is ok. The question is, why does it double the framerate without interaction?

Another problem (maybe specific to the sanyo cam files ... if I select the option "Convert to BT.709 colorspace"

Screenshot4

Then there is no output but an error message that the convertion failed.

[Debug ] "D:/Downloads/PortableSoftware/Shotcut/ffmpeg -loglevel verbose -i E:/Videos/Klingenberg/Klingenberg/100SANYO/SANY0014.MP4 -max_muxing_queue_size 9999 -map 0:V? -map 0:a? -map_metadata 0 -ignore_unknown -vf bwdif,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv422p,scale=flags=accurate_rnd+full_chroma_inp+full_chroma_int:in_range=full:out_range=full -color_range jpeg -f matroska -codec:a pcm_f32le -codec:v utvideo -pix_fmt yuv422p -colorspace bt709 -color_primaries bt709 -color_trc bt709 -y C:/Users/Worker/Pictures/Shotcut_Interlace/SANY0014 - Konvertiert2.mkv" [Info ] job failed with 1

In the first picture it is shown, that the source file has the ITU-R BT.709 colorspace already.

Another problem is, that is seems to be impossible to batch convert files. And the convert dialog looses its settings after each conversation. It would be best that the last settings are persisted somehow.

regards

bmatherly commented 1 year ago

When I open an interlaced video file from my old Sanyo camera it shows a framerate of 59.940060 fps.

This is being misreported by the underlying FFMpeg library. If you want to look deeper, you could use FFProbe to see what the FFMpeg library reports for that file. Possibly related to this issue: https://github.com/mltframework/mlt/issues/898

The question is, why does it double the framerate without interaction?

This is the expected behavior. The deinterlacer converts each field into a new frame to preserve temporal information (since each field comes from a different time).

When I set the framerate in the convert dialog to the 59 fps (like the source) than the deinterlaced video has the 59 fps setting and everything is ok.

This is probably your best workaround to make this file work well for editing.

Then there is no output but an error message that the convertion failed.

Did the progress bar move at all? Or did it fail immediately?

Another problem is, that is seems to be impossible to batch convert files.

Good comment. I have in mind to improve this in a future release.

ddennedy commented 1 year ago

you could use FFProbe to see what the FFMpeg library reports for that file

Shotcut comes with this, and when you use Properties > menu > More Information.. it runs it for you. You can copy and paste its output here.

Please try choosing the option Override frame rate and set it to 59,940060.

The option to convert to BT.709 is primarily intended for converting HDR to SDR. You do not need to do it for BT.601 source, but we can try better to disable that when not needed.

DarkiStar commented 1 year ago

you could use FFProbe to see what the FFMpeg library reports for that file

Shotcut comes with this, and when you use Properties > menu > More Information.. it runs it for you. You can copy and paste its output here.

Wow. That menu was hard to find ... spend more than 5 min ...

ffprobe output

[streams.stream.0] index=0 codec_name=h264 codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 profile=Main codec_type=video codec_tag_string=avc1 codec_tag=0x31637661 width=1920 height=1080 coded_width=1920 coded_height=1080 closed_captions=0 film_grain=0 has_b_frames=0 sample_aspect_ratio=1:1 display_aspect_ratio=16:9 pix_fmt=yuvj420p level=40 color_range=pc color_space=unknown color_transfer=unknown color_primaries=unknown chroma_location=left field_order=tt refs=1 is_avc=true nal_length_size=4 id=0x1 r_frame_rate=60000/1001 avg_frame_rate=60000/1001 time_base=1/60000 start_pts=0 start_time=0:00:00.000000 duration_ts=478478 duration=0:00:07.974633 bit_rate=16.664616 Mbit/s max_bit_rate=N/A bits_per_raw_sample=8 nb_frames=478 nb_read_frames=N/A nb_read_packets=N/A extradata_size=43

[streams.stream.0.disposition] default=1 dub=0 original=0 comment=0 lyrics=0 karaoke=0 forced=0 hearing_impaired=0 visual_impaired=0 clean_effects=0 attached_pic=0 timed_thumbnails=0 captions=0 descriptions=0 metadata=0 dependent=0 still_image=0

[streams.stream.0.tags] creation_time=2014-04-13T10:14:30.000000Z language=eng vendor_id=[0][0][0][0]

[streams.stream.1] index=1 codec_name=aac codec_long_name=AAC (Advanced Audio Coding) profile=LC codec_type=audio codec_tag_string=mp4a codec_tag=0x6134706d sample_fmt=fltp sample_rate=48 KHz channels=2 channel_layout=stereo bits_per_sample=0 id=0x2 r_frame_rate=0/0 avg_frame_rate=0/0 time_base=1/48000 start_pts=0 start_time=0:00:00.000000 duration_ts=382782 duration=0:00:07.974625 bit_rate=128.031000 Kbit/s max_bit_rate=N/A bits_per_raw_sample=N/A nb_frames=374 nb_read_frames=N/A nb_read_packets=N/A extradata_size=2

[streams.stream.1.disposition] default=1 dub=0 original=0 comment=0 lyrics=0 karaoke=0 forced=0 hearing_impaired=0 visual_impaired=0 clean_effects=0 attached_pic=0 timed_thumbnails=0 captions=0 descriptions=0 metadata=0 dependent=0 still_image=0

[streams.stream.1.tags] creation_time=2014-04-13T10:14:30.000000Z language=eng vendor_id=[0][0][0][0]

[format] filename=E:/Videos/Klingenberg/Klingenberg/100SANYO/SANY0014.MP4 nb_streams=2 nb_programs=0 format_name=mov,mp4,m4a,3gp,3g2,mj2 format_long_name=QuickTime / MOV start_time=0:00:00.000000 duration=0:00:07.974633 size=16.250000 Mibyte bit_rate=17.093561 Mbit/s probe_score=100

[format.tags] major_brand=mp42 minor_version=1 compatible_brands=mp42avc1 creation_time=2014-04-13T10:14:30.000000Z original_format=Digital Camera original_format-eng=Digital Camera comment=SANYO DIGITAL CAMERA HD2000 comment-eng=SANYO DIGITAL CAMERA HD2000 Completed successfully in 00:00:00

Please try choosing the option Override frame rate and set it to 59,940060.

Yes. As I wrote in the ticket if I set this value manually in the deinterlace dialog everything seems to be ok. Also the file with double framerate (119) played well but it felt wrong to me ....

@bmatherly

Then there is no output but an error message that the convertion failed. Did the progress bar move at all? Or did it fail immediately?

It opens the file dialog and after setting the filename it fails immediately. No progress bar.

regards

ddennedy commented 1 year ago

Here is the reason why the double the expected frame rate: avg_frame_rate=60000/1001

Sanyo probably set something incorrectly. All of my interlace sources that work correctly (vast majority), it reports avg_frame_rate=30000/1001

There are always going to be some interoperability problems like this that require manual correction.

DarkiStar commented 1 year ago

Here is the reason why the double the expected frame rate: avg_frame_rate=60000/1001

Sanyo probably set something incorrectly. All of my interlace sources that work correctly (vast majority), it reports avg_frame_rate=30000/1001

There are always going to be some interoperability problems like this that require manual correction.

But as I remember, I set the framerate in the camera to 60 fps. So I think the metadata is correct. I was not complaining about the 59 fps of the source file but the (to me) unexpected 120 fps after deinterlacing which is the expected behaviour regarding to the comment from @bmatherly

So I think this issue can be closed ... the batch conversation is more a feature request and the failed color space conversion (because it is not nessecary) is only a small issure.

Thank you for taking time to look into this ....

regards

ddennedy commented 1 year ago

I see. That is odd: I have never run across a 60 fps interlaced video like yours. :-) Shotcut can do deinterlace in realtime if you do not need to increase the frame rate. 60 fps interlace is actually 120 Hz since the field (half the lines of a frame) rate is 120 fields/second. The convert dialog is how Shotcut provides a deinterlace that retains the full frequency by doubling frame rate. But you can override that behavior in case you want to pre-convert to something optimal for your project. In that case, the 601 to 709 conversion should be working too.

DarkiStar commented 1 year ago

I see. That is odd: I have never run across a 60 fps interlaced video like yours. :-) Shotcut can do deinterlace in realtime if you do not need to increase the frame rate. 60 fps interlace is actually 120 Hz since the field (half the lines of a frame) rate is 120 fields/second. The convert dialog is how Shotcut provides a deinterlace that retains the full frequency by doubling frame rate. But you can override that behavior in case you want to pre-convert to something optimal for your project. In that case, the 601 to 709 conversion should be working too.

But according to my first screenshot the source had the 709 colorspace already (not 601). Or do I miss something?

I have a lot of videos taken with that camera. Now I deinterlace them one by one (have to repeat all settings every time :-) ) and try to save them lossless. But the resulting files are huge!!! .... Not sure if there is a better way ...

bmatherly commented 1 year ago

But as I remember, I set the framerate in the camera to 60 fps.

Can you also set the mode to "progressive"? I would question whether these files are really interlaced. If you do not deinterlace, do you see an interlaced combing effect?

DarkiStar commented 1 year ago

But as I remember, I set the framerate in the camera to 60 fps.

Can you also set the mode to "progressive"? I would question whether these files are really interlaced. If you do not deinterlace, do you see an interlaced combing effect?

The files are really interlaced. I can clearly see an interlaced combing effect in the source files (especially in camera pans). And deinterlacing in shortcut does a very good job to eliminate that effect!

I am not sure if the cam has an progressive mode, but I doubt it. I do not have it laying around to do a quick test.

regards