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 aac, m4a, 3gp to allowed audio formats #11342

Merged
merged 1 commit into from
Jul 18, 2019
Merged

Add aac, m4a, 3gp to allowed audio formats #11342

merged 1 commit into from
Jul 18, 2019

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Jul 17, 2019

Fix #11186

@Gargron Gargron merged commit 4906cab into master Jul 18, 2019
@Gargron Gargron deleted the fix-aac-m4a-3gp branch July 18, 2019 01:02
@tateisu
Copy link
Contributor

tateisu commented Jul 18, 2019

(1a)
Galaxy S10's default voice recorder makes "*.m4a" file, but it's file header indicates it is "3gp4".
Sending it from WebUI on Chromw(Windows), its Content-Type header is "audio/x-m4a".
Mastodon returns 422 {"error":"バリデーションに失敗しました: Filehas contents that are not what they are reported to be, Fileは不正な値です, File content typeは不正な値です"}
server log:

[paperclip] Trying to link /tmp/RackMultipart20190718-13-othfiy.m4a to /tmp/ac40e4aeb9b3a9694b25c87029b5da8220190718-13-1d4nxb7.m4a
Command :: file -b --mime '/tmp/ac40e4aeb9b3a9694b25c87029b5da8220190718-13-1d4nxb7.m4a'
[paperclip] Trying to link /tmp/ac40e4aeb9b3a9694b25c87029b5da8220190718-13-1d4nxb7.m4a to /tmp/ac40e4aeb9b3a9694b25c87029b5da8220190718-13-17pbbe4.3gp
Command :: file -b --mime '/tmp/ac40e4aeb9b3a9694b25c87029b5da8220190718-13-17pbbe4.3gp'
[paperclip] Content Type Spoof: Filename d88712ccbce9d44d.3gp (application/octet-stream from Headers, ["video/3gpp"] from Extension), content type discovered from file command: application/octet-stream. See documentation to allow this combination.
[paperclip] Trying to link /tmp/ac40e4aeb9b3a9694b25c87029b5da8220190718-13-1d4nxb7.m4a to /tmp/ac40e4aeb9b3a9694b25c87029b5da8220190718-13-quntcx.3gp
Command :: file -b --mime '/tmp/ac40e4aeb9b3a9694b25c87029b5da8220190718-13-quntcx.3gp'
[paperclip] Content Type Spoof: Filename d88712ccbce9d44d.3gp (application/octet-stream from Headers, ["video/3gpp"] from Extension), content type discovered from file command: application/octet-stream. See documentation to allow this combination.
method=POST path=/api/v1/media format=html controller=Api::V1::MediaController action=create status=422 duration=37.66 view=0.23 db=4.67
Invalid or incomplete POST params

(1b)
Sending it from SubwayTooter, its Content-Type header is "audio/3gpp".
also Mastodon returns 422 {"error":"バリデーションに失敗しました: Filehas contents that are not what they are reported to be, Fileは不正な値です, File content typeは不正な値です"}
server log:

[paperclip] Trying to link /tmp/RackMultipart20190718-13-s6946l.m4a to /tmp/72e35aad684159d540119da1cd513da120190718-13-5r34a3.m4a
Command :: file -b --mime '/tmp/72e35aad684159d540119da1cd513da120190718-13-5r34a3.m4a'
[paperclip] Trying to link /tmp/72e35aad684159d540119da1cd513da120190718-13-5r34a3.m4a to /tmp/72e35aad684159d540119da1cd513da120190718-13-qrlf8m.3gp
Command :: file -b --mime '/tmp/72e35aad684159d540119da1cd513da120190718-13-qrlf8m.3gp'
[paperclip] Content Type Spoof: Filename b3d40c419d261111.3gp (application/octet-stream from Headers, ["video/3gpp"] from Extension), content type discovered from file command: application/octet-stream. See documentation to allow this combination.
[paperclip] Trying to link /tmp/72e35aad684159d540119da1cd513da120190718-13-5r34a3.m4a to /tmp/72e35aad684159d540119da1cd513da120190718-13-19x6dq6.3gp
Command :: file -b --mime '/tmp/72e35aad684159d540119da1cd513da120190718-13-19x6dq6.3gp'
[paperclip] Content Type Spoof: Filename b3d40c419d261111.3gp (application/octet-stream from Headers, ["video/3gpp"] from Extension), content type discovered from file command: application/octet-stream. See documentation to allow this combination.
method=POST path=/api/v1/media format=html controller=Api::V1::MediaController action=create status=422 duration=34.88 view=0.26 db=2.55

(2a)
then I convert audio file to aac.
Sending it from WebUI on Chromw(Windows), its Content-Type header is "audio/vnd.dlna.adts".
Mastodon returns 422 {"error":"バリデーションに失敗しました: File content typeは不正な値です, Fileは不正な値です"}
server log:

Command :: file -b --mime '/tmp/RackMultipart20190718-26-18ot8ui.aac'
[paperclip] Trying to link /tmp/RackMultipart20190718-26-18ot8ui.aac to /tmp/e8fb2bdac00e8168e98e85225b0d512220190718-26-90ete9.aac
Command :: file -b --mime '/tmp/e8fb2bdac00e8168e98e85225b0d512220190718-26-90ete9.aac'
[paperclip] Trying to link /tmp/e8fb2bdac00e8168e98e85225b0d512220190718-26-90ete9.aac to /tmp/e8fb2bdac00e8168e98e85225b0d512220190718-26-558eba
[paperclip] Trying to link /tmp/e8fb2bdac00e8168e98e85225b0d512220190718-26-90ete9.aac to /tmp/e8fb2bdac00e8168e98e85225b0d512220190718-26-5kod8q
method=POST path=/api/v1/media format=html controller=Api::V1::MediaController action=create status=422 duration=34.30 view=0.31 db=3.30

(2b)
Sending it from SubwayTooter, its Content-Type header is "audio/aac".
also Mastodon returns 422 {"error":"バリデーションに失敗しました: Filehas contents that are not what they are reported to be, Fileは不正な値です, File content typeは不正な値です"}
server log:

Command :: file -b --mime '/tmp/RackMultipart20190718-26-1ul5o59.aac'
[paperclip] Trying to link /tmp/RackMultipart20190718-26-1ul5o59.aac to /tmp/8cdd3279980ea4cc4d15280549ace0f420190718-26-gsg6ox.aac
Command :: file -b --mime '/tmp/8cdd3279980ea4cc4d15280549ace0f420190718-26-gsg6ox.aac'
[paperclip] Trying to link /tmp/8cdd3279980ea4cc4d15280549ace0f420190718-26-gsg6ox.aac to /tmp/8cdd3279980ea4cc4d15280549ace0f420190718-26-15q4qy8
[paperclip] Trying to link /tmp/8cdd3279980ea4cc4d15280549ace0f420190718-26-gsg6ox.aac to /tmp/8cdd3279980ea4cc4d15280549ace0f420190718-26-1lm3he2
method=POST path=/api/v1/media format=html controller=Api::V1::MediaController action=create status=422 duration=18.02 view=0.24 db=0.67

(3a)
then I convert audio file to m4a. (truely m4a, not 3gp)
Sending it from WebUI on Chromw(Windows), its Content-Type header is "audio/x-m4a".
Mastodon returns 422 {"error":"バリデーションに失敗しました: File content typeは不正な値です, Fileは不正な値です"}
server log:

[paperclip] Trying to link /tmp/RackMultipart20190718-26-1afvo4.m4a to /tmp/2e6169c805648d9d002765e1ecfaa12a20190718-26-10w9jz3.m4a
Command :: file -b --mime '/tmp/2e6169c805648d9d002765e1ecfaa12a20190718-26-10w9jz3.m4a'
[paperclip] Trying to link /tmp/2e6169c805648d9d002765e1ecfaa12a20190718-26-10w9jz3.m4a to /tmp/2e6169c805648d9d002765e1ecfaa12a20190718-26-1dwi2dm.mp4
Command :: file -b --mime '/tmp/2e6169c805648d9d002765e1ecfaa12a20190718-26-1dwi2dm.mp4'
[paperclip] Trying to link /tmp/2e6169c805648d9d002765e1ecfaa12a20190718-26-10w9jz3.m4a to /tmp/2e6169c805648d9d002765e1ecfaa12a20190718-26-s55ifn.mp4
Command :: file -b --mime '/tmp/2e6169c805648d9d002765e1ecfaa12a20190718-26-s55ifn.mp4'
method=POST path=/api/v1/media format=html controller=Api::V1::MediaController action=create status=422 duration=27.66 view=0.23 db=2.73

(3b)
Sending it from SubwayTooter, its Content-Type header is "audio/m4a".
also Mastodon returns 422 {"error":"バリデーションに失敗しました: Filehas contents that are not what they are reported to be, Fileは不正な値です, File content typeは不正な値です"}
server log:

[paperclip] Trying to link /tmp/RackMultipart20190718-13-cr9sqf.m4a to /tmp/b655b77e2e3aa11b67445ef97bd6a95d20190718-13-1c99mkq.m4a
Command :: file -b --mime '/tmp/b655b77e2e3aa11b67445ef97bd6a95d20190718-13-1c99mkq.m4a'
[paperclip] Trying to link /tmp/b655b77e2e3aa11b67445ef97bd6a95d20190718-13-1c99mkq.m4a to /tmp/b655b77e2e3aa11b67445ef97bd6a95d20190718-13-m62fo5.mp4
Command :: file -b --mime '/tmp/b655b77e2e3aa11b67445ef97bd6a95d20190718-13-m62fo5.mp4'
[paperclip] Trying to link /tmp/b655b77e2e3aa11b67445ef97bd6a95d20190718-13-1c99mkq.m4a to /tmp/b655b77e2e3aa11b67445ef97bd6a95d20190718-13-cso77.mp4
Command :: file -b --mime '/tmp/b655b77e2e3aa11b67445ef97bd6a95d20190718-13-cso77.mp4'
method=POST path=/api/v1/media format=html controller=Api::V1::MediaController action=create status=422 duration=22.00 view=0.24 db=2.09

(4a)
then I rename original m4a(internally 3gp) to .3gp
Sending it from WebUI on Chromw(Windows), its Content-Type header is "video/3gpp".
Mastodon returns 422 {"error":"バリデーションに失敗しました: Filehas contents that are not what they are reported to be, Fileは不正な値です, File content typeは不正な値です"}
server log:

[paperclip] Trying to link /tmp/RackMultipart20190718-13-kfrzey.3gp to /tmp/91833b68dc524a92e39b5fa2efe4ac8a20190718-13-1r1mn6p.3gp
Command :: file -b --mime '/tmp/91833b68dc524a92e39b5fa2efe4ac8a20190718-13-1r1mn6p.3gp'
[paperclip] Trying to link /tmp/91833b68dc524a92e39b5fa2efe4ac8a20190718-13-1r1mn6p.3gp to /tmp/91833b68dc524a92e39b5fa2efe4ac8a20190718-13-1wa0z5y.3gp
Command :: file -b --mime '/tmp/91833b68dc524a92e39b5fa2efe4ac8a20190718-13-1wa0z5y.3gp'
[paperclip] Content Type Spoof: Filename cc065f1c7cee9067.3gp (application/octet-stream from Headers, ["video/3gpp"] from Extension), content type discovered from file command: application/octet-stream. See documentation to allow this combination.
[paperclip] Trying to link /tmp/91833b68dc524a92e39b5fa2efe4ac8a20190718-13-1r1mn6p.3gp to /tmp/91833b68dc524a92e39b5fa2efe4ac8a20190718-13-1mkh05d.3gp
Command :: file -b --mime '/tmp/91833b68dc524a92e39b5fa2efe4ac8a20190718-13-1mkh05d.3gp'
[paperclip] Content Type Spoof: Filename cc065f1c7cee9067.3gp (application/octet-stream from Headers, ["video/3gpp"] from Extension), content type discovered from file command: application/octet-stream. See documentation to allow this combination.
method=POST path=/api/v1/media format=html controller=Api::V1::MediaController action=create status=422 duration=37.67 view=0.23 db=2.90

(4b)
Sending it from Subway Tooter, but Android's Media Scanner handles it is video, SAF content chooser show it as greyed and unselecteble.

@tateisu
Copy link
Contributor

tateisu commented Jul 18, 2019

Also I have tried WebUI on Chrome(Android).
it sent multipart request with following header part .
in this case AAC's Content-Type is different to Chrome(Windows).

Content-Disposition: form-data; name="file"; filename="gs10plus.m4a"
Content-Type: audio/x-m4a

Content-Disposition: form-data; name="file"; filename="gs10plus.aac"
Content-Type: audio/aac

Content-Disposition: form-data; name="file"; filename="gs10plus_2.m4a"
Content-Type: audio/x-m4a

Content-Disposition: form-data; name="file"; filename="gs10plus.3gp"
Content-Type: video/3gpp

@tateisu
Copy link
Contributor

tateisu commented Jul 18, 2019

testdata.zip

@tateisu
Copy link
Contributor

tateisu commented Jul 18, 2019

my test server uses Docker, the Dockerfile is based on FROM ubuntu:18.04.

but file command in ubuntu 18 does not support 3gp file header.

$ cat /etc/issue
Ubuntu 18.04.2 LTS \n \l
$ file -i *
gs10plus_2.m4a: audio/x-m4a; charset=binary
gs10plus.3gp:   application/octet-stream; charset=binary
gs10plus.aac:   audio/x-hx-aac-adts; charset=binary
gs10plus.m4a:   application/octet-stream; charset=binary

@tateisu
Copy link
Contributor

tateisu commented Jul 19, 2019

Ubuntu 19.04's file command detects "video/3gpp" for 3gp audio file.
It's better than Ubuntu 18.04, but still we need some special case for this type.

# cat /etc/issue
Ubuntu 19.04 \n \l
# file -i gs*
gs10plus.3gp:   video/3gpp; charset=binary
gs10plus.aac:   audio/x-hx-aac-adts; charset=binary
gs10plus.m4a:   video/3gpp; charset=binary
gs10plus_2.m4a: audio/x-m4a; charset=binary

@tribela
Copy link
Contributor

tribela commented Dec 10, 2020

Cannot upload m4a audio causes 422 video has no video stream

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.

Audio format from mobile OS's voice recorder
4 participants