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

Encoding profiles - Add custom resolution for PAL 720x576 standards #1018

Open
TheITguy21 opened this issue May 14, 2024 · 2 comments
Open
Assignees

Comments

@TheITguy21
Copy link

TheITguy21 commented May 14, 2024

Hi, I've just discovered and installed MediaCMS a couple days, and it is an amazing product, thank you so much to have made this possible !

It's possible to add a new encoding profile via the django administration site, but the resolutions available are fixed in the list :

image

All my legacy videos are PAL 720x576 (yeah, I'm part of the elite who doesn't have to use NTSC standards 😀), but obviously they're transcoded in 480p once uploaded. I don't want to consider upscaling my videos to 720p just to avoid them to be downgraded to 480p and loosing original resolution quality. But I can't create a 576p profile 😭

Here's what I've tried so far :

  • Create the profile directly in the database from psql :
    insert into files_encodeprofile values ('<Next Id value>', 'h264-576', 'mp4', '576', 'h264', '', 't');
    -> The profile is indeed added to the list, but the resolution is not added/set in the list :

image

  • Edit the following files to add 576 resolution to the existing profiles (I'm not sure what I'm doing 😅) :
/home/mediacms.io/mediacms/files/models.py
/home/mediacms.io/mediacms/fixtures/encoding_profiles.json

-> Same results

REQUEST
Would it be possible to implement the possibility to add a custom resolution ?
Or if its not that simple (because maybe they're also other things to set for each resolution, such as bitrate etc to drive ffmpeg), maybe at least to have the information on what has to be edited in files or database to achieve this ?

Thank you !

@TheITguy21 TheITguy21 changed the title Encoding profiles - Add custom resolution for standard PAL 720x576 Encoding profiles - Add custom resolution for PAL 720x576 standards May 14, 2024
@TheITguy21
Copy link
Author

TheITguy21 commented May 14, 2024

Ok I figured it out 😊 Here's what I did :

  • Edit the following files to add anything related to the "576" resolution, based on existing profiles (I search for the arbitrary value "1440" everywhere within files, I knew it would return something related to encoding resolution)
/home/mediacms.io/mediacms/files/helpers.py
/home/mediacms.io/mediacms/files/models.py

Example from helpers.py (search everywhere in the file !)
image

  • Restart mediacms service (I'm not sure if it was necessary, I wanted to be sure the value comes up in encoding profiles administration)

  • Created a new encoding profile : the "576" resolution was present in the resolution list !
    image

  • Reboot the host (restart mediacms service was not enough)

Then I uploaded a 576p video, and the encoding to 576p succeed and was available !
image
image
image

I hope this will help 😊

If this tweaking can be simplified by natively integrating "576p" profiles, that would be perfect. Thanks !
Keep up the good work !

FI : I'm not runnnig MediaCMS on docker.

@TheITguy21
Copy link
Author

TheITguy21 commented May 18, 2024

Just in case it helps someone, here's the code to update the files from bash using sed on Debian.
It might not be the most elegant syntax, but it works.
Note : It updates the 60fps profiles, too. In my case I have some PAL 25fps videos deinterlaced to progressive 50fps, (it could be 30fps480i deinterlaced to 60fps480p), that would be a shame if they're processed with the same bitrate as the 25fps profiles just because the 480/576 resolution are missing from the 60fps profiles 😅
(I've understood that in normal circumstances, the videos are encoded with 'crf', so those bitrates shouldn't be used but anyway..just in case 😉)

  • /home/mediacms.io/mediacms/files/helpers.py
# Update 25fps profiles
sudo sed -i -E '/^(\s|\t)*576: [0-9]+,.*$/d' /home/mediacms.io/mediacms/files/helpers.py
sudo sed -i -E '/"h264": \{/,/^(\s{4}|\t)\},/{ /25: \{/,/\}/{ s@^(((\s|\t)*)720: ([0-9]+),)@\2576: 1800,\n\1@ } }'  /home/mediacms.io/mediacms/files/helpers.py
sudo sed -i -E '/"h265": \{/,/^(\s{4}|\t)\},/{ /25: \{/,/\}/{ s@^(((\s|\t)*)720: ([0-9]+),)@\2576: 700,\n\1@ } }'  /home/mediacms.io/mediacms/files/helpers.py
sudo sed -i -E '/"vp9": \{/,/^(\s{4}|\t)\},/{ /25: \{/,/\}/{ s@^(((\s|\t)*)720: ([0-9]+),)@\2576: 700,\n\1@ } }'  /home/mediacms.io/mediacms/files/helpers.py
# Update 60fps profiles
sudo sed -i -E "/\"h264\": \{/,/^(\s{4}|\t)\},/{ /60: \{/{ s@\{([^,]+, )*720:@\{480: 1500, 576: 2600, 720:@ } }" /home/mediacms.io/mediacms/files/helpers.py
sudo sed -i -E "/\"h265\": \{/,/^(\s{4}|\t)\},/{ /60: \{/{ s@\{([^,]+, )*720:@\{480: 800, 576: 1200, 720:@ } }" /home/mediacms.io/mediacms/files/helpers.py
sudo sed -i -E "/\"vp9\": \{/,/^(\s{4}|\t)\},/{ /60: \{/{ s@\{([^,]+, )*720:@\{480: 800, 576: 1200, 720:@ } }" /home/mediacms.io/mediacms/files/helpers.py

Results :
image

  • /home/mediacms.io/mediacms/files/models.py
# Declare 576 encoding resolution as available
sudo sed -i -E '/^ENCODE_RESOLUTIONS = \(/,/^\)/{ /\(576,/d ; s@^(((\s|\t)*)\(720,.+)$@\1\n\2(576, "576"),@ }' /home/mediacms.io/mediacms/files/models.py
sudo sed -i -E '/^(\s|\t)*valid_resolutions =/ { s@480, ([0-9]+, )*720,@480, 576, 720,@ }' /home/mediacms.io/mediacms/files/models.py

Results :
image
image

Make sure to reboot to apply changes (in my case restarting mediacms service was not enough : the 576 encode failed)

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants