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

Add more media formats #11687

Merged
merged 2 commits into from
Aug 30, 2019
Merged

Add more media formats #11687

merged 2 commits into from
Aug 30, 2019

Conversation

umonaca
Copy link
Contributor

@umonaca umonaca commented Aug 28, 2019

Add file extension support for .amr .wma.
Add MIME types:audio/x-m4a audio/mp4 audio/amr video/x-ms-asf.
Example: This media file has an file extension name of m4a, but it cannot be uploaded to mastodon.social. Simply adding an audio/x-m4a will fix this bug.

@trwnh
Copy link
Member

trwnh commented Aug 29, 2019

  • AMR and WMA is not playable in browsers.
  • M4A is simply an extension, what matters is the audio/mp4 type (since it's AAC audio in MP4 container).

@umonaca
Copy link
Contributor Author

umonaca commented Aug 29, 2019

About audio/x-m4a:
I have tested on a real production server. Adding audio/x-m4a to that line fixed the problem of not being able to upload that type of media file. Our users were complaining 422 error when uploading their media files recorded on their phone, but now it is fixed.

@Gargron
Copy link
Member

Gargron commented Aug 30, 2019

AMR and WMA is not playable in browsers.

All allowed formats are transcoded into mp3. However, AMR seems like a very rare format. I have never heard of it until now. Also, is it confirmed that WMA can be converted by ffmpeg? It's from Microsoft so it could be proprietary.

@Gargron Gargron merged commit 7235f53 into mastodon:master Aug 30, 2019
@umonaca
Copy link
Contributor Author

umonaca commented Aug 30, 2019

  • For audio/x-m4a
    I have tested removing audio/x-m4a but keeping audio/mp4. No it's not working. The reason is quite simple: file -b --mime is executed and the result does not match the string audio/x-m4a.
  • For WMA
    I have tested both in local development environment and in our production server (Ubuntu). It works. FFmpeg automatically converts the file into an .mp3 file and the site is serving the converted .mp3 file. To get the conversion working, video/x-ms-asf must be kept in AUDIO_MIME_TYPES.
    Although it works, it's kind of weird that the file is converted into an .asf file with MIME type video/x-ms-asf rather than directly converted to .mp3.
    The log on development environment when a wma is uploaded:

22:19:08 web.1 | [paperclip] Trying to link /tmp/RackMultipart20190829-23140-tqgcig.wma to /tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m.wma
22:19:08 web.1 | Command :: file -b --mime '/tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m.wma'
22:19:08 web.1 | [paperclip] Trying to link /tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m.wma to /tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-6g5a2l.asf
22:19:08 web.1 | Command :: file -b --mime '/tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-6g5a2l.asf'
22:19:08 web.1 | [AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
22:19:08 web.1 | [AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
22:19:08 web.1 | [AV] Found ["ffmpeg"], using: Ffmpeg
22:19:08 web.1 | [AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
22:19:08 web.1 | [AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
22:19:08 web.1 | [AV] Found ["ffmpeg"], using: Ffmpeg
22:19:08 web.1 | [AV] Running command: ffmpeg -i "/tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m.wma" 2>&1
22:19:08 web.1 | [paperclip] [transcoder] Transocding supported file /tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m.wma
22:19:08 web.1 | [AV] Adding output parameter ["q:a", 2]
22:19:08 web.1 | [AV] Running command: ffmpeg -i "/tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m.wma" -q:a 2 -y "/tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m20190829-23140-fz6x1e.mp3"
22:19:08 web.1 | [paperclip] [transcoder] Successfully transcoded ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m to #File:0x00007ff81c6b9c90
22:19:08 web.1 | [paperclip] Trying to link /tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-bmvy0m20190829-23140-fz6x1e.mp3 to /tmp/a7e2f4d1c12a43d855f199695db1f31120190829-23140-1i9drnx.mp3
22:19:08 web.1 | (0.2ms) BEGIN
22:19:08 web.1 | [paperclip] Trying to link /tmp/a7e2f4d1c12a43d855f199695db1f31120190829-23140-1i9drnx.mp3 to /tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-txioxn.mp3
22:19:08 web.1 | Command :: file -b --mime '/tmp/ce53f868336994c4e658e84f5f912a0920190829-23140-txioxn.mp3'

  • For AMR
    Now I removed AMR from this PR.

@umonaca umonaca deleted the vanilla branch August 30, 2019 07:39
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* Add more media formats

* Removed amr file type
rtucker pushed a commit to vulpineclub/mastodon that referenced this pull request Jan 7, 2021
* Add more media formats

* Removed amr file type
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

Successfully merging this pull request may close these issues.

None yet

3 participants