Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ffmpeg #1246

Open
wants to merge 3 commits into
base: pod_V4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pod/main/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -4074,7 +4074,7 @@
"pod_version_init": "3.1.0"
},
"FFMPEG_CREATE_THUMBNAIL": {
"default_value": "-vf \"fps=1/(%(duration)s/%(nb_thumbnail)s)\" -vsync vfr \"%(output)s_%%04d.png\"",
"default_value": "-vf \"fps=1/(%(duration)s/%(nb_thumbnail)s)\" -fps_mode passthrough \"%(output)s_%%04d.png\"",
"description": {
"en": [
""
Expand Down Expand Up @@ -4230,7 +4230,7 @@
"pod_version_init": "3.1.0"
},
"FFMPEG_MP4_ENCODE": {
"default_value": "-map 0:v:0 %(map_audio)s -c:v %(libx)s -vf \"scale=-2:%(height)s\" -preset %(preset)s -profile:v %(profile)s -pix_fmt yuv420p -level %(level)s -crf %(crf)s -maxrate %(maxrate)s -bufsize %(bufsize)s -sc_threshold 0 -force_key_frames \"expr:gte(t,n_forced*1)\" -max_muxing_queue_size 4000 -c:a aac -ar 48000 -b:a %(ba)s -movflags faststart -y -vsync 0 \"%(output)s\"",
"default_value": "-map 0:v:0 %(map_audio)s -c:v %(libx)s -vf \"scale=-2:%(height)s\" -preset %(preset)s -profile:v %(profile)s -pix_fmt yuv420p -level %(level)s -crf %(crf)s -maxrate %(maxrate)s -bufsize %(bufsize)s -sc_threshold 0 -force_key_frames \"expr:gte(t,n_forced*1)\" -max_muxing_queue_size 4000 -c:a aac -ar 48000 -b:a %(ba)s -movflags faststart -y -fps_mode passthrough \"%(output)s\"",
"description": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Juste pour comprendre, ca signifie que vsync 0 et vsync vfr étaient équivalents ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non voilà l'explication de notre ami ChatGPT

-vsync 0 : Pour préserver exactement les horodatages d'entrée dans la sortie, utile dans les scénarios de remuxage ou d'encodage spécifique.
-vsync vfr : Lors de l'encodage pour des fréquences d'images variables ou si la chronologie des images d'entrée doit être respectée, mais la sortie ne nécessite pas des intervalles d'images fixes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

du coup, est-ce judicieux de remplacer "vsync 0" et "vsync vfr" par "fps_mode passthrough", ou y aurait-t-il un autre fps_mode plus adapté ?

"en": [
""
Expand Down
2 changes: 1 addition & 1 deletion pod/video_encode_transcript/encoding_settings.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense qu'il faudrait aussi remplacer les "vsync" qu'on trouve dans "FFMPEG_CREATE_THUMBNAIL", "FFMPEG_CREATE_OVERVIEW" et "FFMPEG_DRESSING_OUTPUT" dans ce fichier

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok je vais regarder.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
+ "-maxrate %(maxrate)s -bufsize %(bufsize)s "
+ '-sc_threshold 0 -force_key_frames "expr:gte(t,n_forced*1)" '
+ "-max_muxing_queue_size 4000 "
+ '-c:a aac -ar 48000 -b:a %(ba)s -movflags faststart -y -vsync 0 "%(output)s" '
+ '-c:a aac -ar 48000 -b:a %(ba)s -movflags faststart -y -fps_mode passthrough "%(output)s" '
)
# https://gist.github.com/Andrey2G/78d42b5c87850f8fbadd0b670b0e6924
FFMPEG_HLS_COMMON_PARAMS = (
Expand Down
18 changes: 12 additions & 6 deletions pod/video_encode_transcript/encoding_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ def get_sub_cmd(height_presentation_video, height_presenter_video, presenter):
# -vsync 0 outputVideo.mp4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il reste encore un subcmd = " -vsync 0 " (ligne 75)
et ptet en profiter pour virer les commentaires lignes 91-94 et 108-111 ?

subcmd = (
" -filter_complex "
+ '"[0:v]scale=-2:%(height)s[pres];[1:v]scale=-2:%(sh)s[pip];'
+ '"[0:v]bwdif=mode=send_field:parity=auto:deint=all[presdeint];'
+ '[1:v]bwdif=mode=send_field:parity=auto:deint=all[pipdeint];'
+ '[presdeint]scale=-2:%(height)s[pres];[pipdeint]scale=-2:%(sh)s[pip];'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ca fait beaucoup de lignes en plus ^^. Tu saurais expliquer à un néophite le changement ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai seulement suivi les propositions issues du Backlog. Je ne suis pas un spécialiste sur ffmpeg mais je peux creuser.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si tu peux creuser ce serait pas mal merci. Je suis pas fan de pousser des modifs si personne ne sait ce qu'elle font ^^.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu sais qui est à l'origine de ces modifs ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est Ulysseus, mais il me semble qu'il me disait avoir juste fait du "bidouillage" sur FFMPEG, c'est pourquoi j'ai préféré le confier à une personne s'y connaissant un minimum en encodage ^^.

% {"height": height, "sh": height / 4}
+ '[pres][pip]overlay=W-w-10:H-h-10:shortest=1" -vsync 0 '
+ '[pres][pip]overlay=W-w-10:H-h-10:shortest=1" -fps_mode passthrough '
)
if presenter == "piph":
# trouver la bonne hauteur en fonction de la video de presentation
Expand All @@ -111,9 +113,11 @@ def get_sub_cmd(height_presentation_video, height_presenter_video, presenter):
# -vsync 0 outputVideo.mp4
subcmd = (
" -filter_complex "
+ '"[0:v]scale=-2:%(height)s[pres];[1:v]scale=-2:%(sh)s[pip];'
+ '"[0:v]bwdif=mode=send_field:parity=auto:deint=all[presdeint];'
+ '[1:v]bwdif=mode=send_field:parity=auto:deint=all[pipdeint];'
+ '[presdeint]scale=-2:%(height)s[pres];[pipdeint]scale=-2:%(sh)s[pip];'
% {"height": height, "sh": height / 4}
+ '[pres][pip]overlay=W-w-10:10:shortest=1" -vsync 0 '
+ '[pres][pip]overlay=W-w-10:10:shortest=1" -fps_mode passthrough '
)
if presenter == "mid":
height = min_height if (min_height % 2) == 0 else min_height + 1
Expand All @@ -122,9 +126,11 @@ def get_sub_cmd(height_presentation_video, height_presenter_video, presenter):
# outputVideo.mp4
subcmd = (
" -filter_complex "
+ '"[0:v]scale=-2:%(height)s[left];[1:v]scale=-2:%(height)s[right];'
+ '"[0:v]bwdif=mode=send_field:parity=auto:deint=all[presdeint];'
+ '[1:v]bwdif=mode=send_field:parity=auto:deint=all[pipdeint];'
+ '[presdeint]scale=-2:%(height)s[left];[pipdeint]scale=-2:%(height)s[right];'
% {"height": height}
+ '[left][right]hstack" -vsync 0 '
+ '[left][right]hstack" -fps_mode passthrough '
)

return subcmd
Expand Down