mpeg5 / xeve

eXtra-fast Essential Video Encoder, MPEG-5 EVC (Essential Video Coding)
Other
166 stars 39 forks source link

Is there 23.976 or 29.97 fps setting in XEVE #109

Closed i990049 closed 4 months ago

i990049 commented 5 months ago

If someone know how to set XEVE 23.976 or 29.97 in FFmpeg, that'll be helpful.thank you. https://patchwork.ffmpeg.org/project/ffmpeg/patch/035001d82fc3$bddfd240$399f76c0$@samsung.com/

dkozinski commented 5 months ago

Just use the r option when coding.

/ffmpeg -f lavfi -i testsrc -r 29.97 -pix_fmt yuv420p10le -t 20 -s 640x480 -vcodec evc testsrc-evc.mp4

ffmpeg -i input.mp4 -r 30000/1001 output.mp4

Just use the r option when coding.

ffmpeg -f lavfi -i testsrc -r 29.97 -pix_fmt yuv420p10le -t 20 -s 640x480 -vcodec evc testsrc-evc.mp4

ffmpeg -i input.mp4 -r 30000/1001 output.mp4

Selur commented 5 months ago

ffmpeg -i input.mp4 -r 30000/1001 output.mp4 will only change the frame rate of the container, so that is not a solution. If unlike the xeve_app ffmpeg supports non integer frame rates, that would work.

Selur commented 5 months ago

Looking at https://github.com/mpeg5/xeve/blob/d0298b5be7426db3e124244c70a094455551b86b/app/xeve_app.c#L367 it seems like fractional frame rates are supported when fed with y4m. => nope, when '--fps xx' isn't set xeve_app will use 25fps

using:

ffmpeg -y  -r 24000/1001 -i "G:\Output\2024-05-27@15_11_28_6110\Touhou clip_1_2024-05-27@15_11_28_6110_03.evc" -metadata encoding_tool="Hybrid 2024.05.27.1" -c:v copy -map 0:0   -aspect 640:360 -r 24000/1001 "G:\Output\Touhou clip.mp4"

does not work either. (mediainfo still reports 25fps)

Selur commented 5 months ago

using:

vspipe "G:\Output\encodingTempSynthSkript_2024-05-27@15_52_49_8010_0.vpy" - -c y4m | xeve-base --verbose 2 --input stdin --input-depth 10 --input-csp 1 --fps 24 --codec-bit-depth 10  --rc-type 0 --qp 32 --profile baseline --level-idc 0 --preset medium --info 1 --aq-mode 0 --range limited --matrix-coefficients bt470bg --sar 1:1 --output "G:\Output\test_1_2024-05-27@15_52_49_8010_02.evc"

ffprobe reports 25fps for the output. additionally using:

ffmpeg -y  -r 24000/1001 -i "G:\Output\test_1_2024-05-27@15_52_49_8010_02.evc" -c:v copy -map 0:0   -aspect 640:352 -r 24000/1001 "G:\Output\test.mp4"

both ffprobe and mediainfo report 25fps. => at least xeve_app atm. only outputs 25fps.

Selur commented 5 months ago

Using xeve through ffmpeg supports all frame rates, using it through xeve_app not.

dkozinski commented 5 months ago

FPS information provided to the encoder during encoding does not propagate to the EVC elementary stream. At least not so that it can be used when playing an EVC stream.

Encoding

./xeve_app -i akiyo_cif.yuv -w 352 -h 288 -z 2 -o akiyo_cif-fps-2.evc
./xeve_app -i akiyo_cif.yuv -w 352 -h 288 -z 14.5 -o akiyo_cif-fps-14.5.evc

ffprobe akiyo_cif-fps-2.evc ...

Input #0, evc, from 'akiyo_cif-fps-2.evc':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: evc (Baseline), yuv420p10le, 352x288, 25 fps, 25 tbr, 1200k tbn

ffprobe akiyo_cif-fps-14.5.evc ...

nput #0, evc, from 'akiyo_cif-fps-14.5.evc':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: evc (Baseline), yuv420p10le, 352x288, 25 fps, 25 tbr, 1200k tbn

Decoding

./xevd_app -i akiyo_cif-fps-2.evc -o akiyo_cif-fps-2.y4m
./xevd_app -i akiyo_cif-fps-14.5.evc -o akiyo_cif-fps-14.5.y4m

ffprobe akiyo_cif-fps-2.y4m ...

Input #0, yuv4mpegpipe, from 'akiyo_cif-fps-2.y4m':
  Duration: 00:00:10.00, start: 0.000000, bitrate: 36496 kb/s
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(progressive), 352x288, 30 fps, 30 tbr, 30 tbn

ffprobe akiyo_cif-fps-14.5.y4m ...

Input #0, yuv4mpegpipe, from 'akiyo_cif-fps-14.5.y4m':
  Duration: 00:00:10.00, start: 0.000000, bitrate: 36496 kb/s
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(progressive), 352x288, 30 fps, 30 tbr, 30 tbn
mpeg5 commented 5 months ago

Hi @dkozinski Actually frame rate (fps) information doesn't have to be correct inside of XEVE encoder because it is used only for bit rate calculation. 29.97 Hz can be converted to 30 Hz. the difference (0.03) doesn't affect to rate controller noticably.

Of course, we could change XEVE_PARAM easily, but it will lead API changing, definately. @dkozinski , do you think this parameter should be changed to like floating point? Can we manage API change at this moment? (ffmpeg code should be changed also at the same time)

dkozinski commented 5 months ago

Hi @dkozinski Actually frame rate (fps) information doesn't have to be correct inside of XEVE encoder because it is used only for bit rate calculation. 29.97 Hz can be converted to 30 Hz. the difference (0.03) doesn't affect to rate controller noticably.

Of course, we could change XEVE_PARAM easily, but it will lead API changing, definately. @dkozinski , do you think this parameter should be changed to like floating point? Can we manage API change at this moment? (ffmpeg code should be changed also at the same time)

As it comes to changing XEVE_PARAM::fps field type from int to float/double in libxeve library it will require only cosmetic changes in our FFmpeg implementation. The change won't cause any serious building nor execution issues however we'll push appropriate patches to FFmpeg after changes in libxeve.

You can consider using AVRational like structure for fps representation like FFmpeg do. In FFmpeg for framerate definition AVRational type is used. So 29.97 fps can be easily represented as 30,000/1,001 (AVRational.num = 30000, AVRational.denum=1001).

@Jamaika1 has provided PR #111 that changes fps type from int to double. https://github.com/mpeg5/xeve/pull/111

mpeg5 commented 5 months ago

Decision; The XEVE_PARAM:fps will be removed and newly fps_num and fps_denum will be introduced.

@mss-park , let's patch this code as soon as possible. And, @Jamaika1 , thanks for your help to try to change fps type to double.

mpeg5 commented 4 months ago

PR https://github.com/mpeg5/xeve/pull/116 has merged

Selur commented 4 months ago

The XEVE_PARAM:fps will be removed and newly fps_num and fps_denum will be introduced.

Any plans to also update xeve_app ?

dariusz-f commented 4 months ago

The XEVE_PARAM:fps will be removed and newly fps_num and fps_denum will be introduced.

Any plans to also update xeve_app ?

It is already implemented, if you have any problem please open new issue.

Selur commented 4 months ago

Will test later, just checked the help, which only states:

  -z, --fps [STRING]
    : frame rate (frame per second)

so using --fps 23.976 should work now, or should fps_num and fps_denum be used somehow? should --fps 24000/1001 work?

Selur commented 4 months ago

Using https://github.com/mpeg5/xeve/actions/runs/9641658833 and:

ffmpeg -y -loglevel fatal -noautorotate -nostdin -threads 8 -i "G:\TestClips&Co\files\i.mkv" -map 0:0 -an -sn -vf yadif=0:1 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv -pix_fmt yuv420p10le -strict -1 -vsync 0 -f yuv4mpegpipe - | xeve-base --verbose 2 --input stdin --input-depth 10 --input-csp 1 --fps 29.97 --codec-bit-depth 10  --rc-type 0 --qp 32 --profile baseline --level-idc 0 --preset medium --info 1 --aq-mode 0 --range limited --matrix-coefficients bt709 --sar 1:1 --output "G:\Output\i_1_2024-06-27@16_56_43_7610_01.evc"

and:

ffmpeg -y  -r 30000/1001 -i "G:\Output\i_1_2024-06-27@16_56_43_7610_01.evc" -metadata encoding_tool="Hybrid 2024.06.27.1" -c:v copy -map 0:0   -aspect 1920:1080 -r 30000/1001 "G:\Output\i.mp4"

I get:

MediaInfo.exe g:\Output\i.mp4
General
Complete name                            : g:\Output\i.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/mp41)
File size                                : 90.7 KiB
Duration                                 : 2 s 400 ms
Overall bit rate                         : 310 kb/s
Frame rate                               : 25.000 FPS
Writing application                      : Hybrid 2024.06.27.1

Video
ID                                       : 1
Format                                   : evc1
Codec ID                                 : evc1
Duration                                 : 2 s 400 ms
Bit rate                                 : 302 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Bits/(Pixel*Frame)                       : 0.006
Stream size                              : 88.3 KiB (97%)

=> please, adjust the help so know how to set decimal or fractional frame rates using xeve_app, assuming it is possible now. (here are the output files: Output.zip)

dariusz-f commented 4 months ago

It's required change in FFmpeg EVC integration to support new FPS setting way. Patch is already waiting in FFmpeg queue. https://github.com/mpeg5/xeve/issues/120#issuecomment-2188811446

dariusz-f commented 4 months ago

Fix has been integrated with latest FFmpeg HEAD.

Selur commented 3 months ago

What about the xeve app (xeve-base/xeve-main)? Will there be an update/release to it, so I can use the calls I used above to get a file with proper fps?

i990049 commented 3 months ago

Failed to apply patch https://patchwork.ffmpeg.org/project/ffmpeg/patch/035001d82fc3$bddfd240$399f76c0$@samsung.com/

dariusz-f commented 3 months ago

Failed to apply patch https://patchwork.ffmpeg.org/project/ffmpeg/patch/035001d82fc3$bddfd240$399f76c0$@samsung.com/

You linking old patchset. All EVC changes are integrated since FFmpeg 7.0 please use latest version

dariusz-f commented 3 months ago

What about the xeve app (xeve-base/xeve-main)? Will there be an update/release to it, so I can use the calls I used above to get a file with proper fps?

This is old closed issue. If you have problem please open new issue and describe problem there. Any comments in closed thread may be missed.