Opened 23 months ago

Closed 21 months ago

Last modified 19 months ago

#9807 closed defect (fixed)

decryption_key: subsample size exceeds the packet size left

Reported by: svnpenn Owned by: Shuangxi,Li
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: svnpenn, Shuangxi,Li Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Using this file (35 kB):

https://user-images.githubusercontent.com/73562167/172298706-78ff0077-3394-456a-a174-3cd7b7c499e0.mp4

I get this result:

> ffmpeg -decryption_key 22bdb0063805260307ee5045c0f3835a -i enc.mp4 -c copy dec.mp4
ffmpeg version 5.0.1-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000015ce989b240] subsample size exceeds the packet size left
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000015ce989b240] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(tv, bt709, progressive), 508x254, 13 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'enc.mp4':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    creation_time   : 2022-02-07T20:53:17.000000Z
  Duration: 00:00:17.59, bitrate: 15 kb/s
  Stream #0:0[0x1](eng): Video: h264 (avc1 / 0x31637661), none(tv, bt709, progressive), 508x254, 13 kb/s, SAR 1:1 DAR 2:1, 23.98 fps, 24k tbr, 24k tbn (default)
    Metadata:
      creation_time   : 2022-02-07T20:53:17.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](eng): Subtitle: eia_608 (c608 / 0x38303663), 0 kb/s (default)
    Metadata:
      creation_time   : 2022-02-07T20:53:17.000000Z
      handler_name    : Core Media Closed Caption
    Side data:
      unknown side data type 24 (538 bytes)
Output #0, mp4, to 'dec.mp4':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    encoder         : Lavf59.16.100
  Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), none(tv, bt709, progressive), 508x254 [SAR 1:1 DAR 2:1], q=2-31, 13 kb/s, 23.98 fps, 24k tbr, 24k tbn (default)
    Metadata:
      creation_time   : 2022-02-07T20:53:17.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000015ce989b240] subsample size exceeds the packet size left
enc.mp4: Invalid data found when processing input

Other tools work as expected:

mp4decrypt --key 1:22bdb0063805260307ee5045c0f3835a enc.mp4 dec.mp4

Attachments (1)

dec1.mp4 (32.1 KB ) - added by Balling 23 months ago.

Download all attachments as: .zip

Change History (13)

comment:1 by svnpenn, 23 months ago

Cc: svnpenn added

comment:2 by Balling, 23 months ago

This is what mp4decrypt from here https://www.bento4.com/downloads/ produces, AVC CABAC with 5 ref frames, nice:

by Balling, 23 months ago

Attachment: dec1.mp4 added

comment:3 by Shuangxi,Li, 22 months ago

Cc: Shuangxi,Li added

The CENC decryption function has a bug, In the funciton cenc_scheme_decrypt,Partially_encrypted_block_size may be a negative value. Therefore, a core dump occurs when memcpy(block, partially_encrypted_block, partially_encrypted_block_size); is executed.

comment:4 by Shuangxi,Li, 22 months ago

Owner: set to Shuangxi,Li
Status: newopen

comment:6 by Shuangxi,Li, 22 months ago

you just upload the dec1.mp4 file(It's a decrypted file). can you upload enc.mp4 file. Or can you describe how you encrypted the dec1.mp4 file to get the enc.mp4 file? thank you.

in reply to:  6 comment:7 by Balling, 22 months ago

Replying to Shuangxi,Li:

you just upload the dec1.mp4 file(It's a decrypted file). can you upload enc.mp4 file. Or can you describe how you encrypted the dec1.mp4 file to get the enc.mp4 file? thank you.

https://user-images.githubusercontent.com/73562167/172298706-78ff0077-3394-456a-a174-3cd7b7c499e0.mp4

comment:9 by Balling, 21 months ago

Resolution: fixed
Status: openclosed

Fixed by 1af7797d212eee9aa86a54f558bcfe6abb22949b. But looks like some closed captions are not preserved (-copyts is needed to preserve 10 second initial timestamp). It also does not do faststart, so moov is in the end. But that is good, I think.

comment:10 by Vitaly Ivanov, 19 months ago

It's a long shot, but can you recommend a method to work around this issue? I need to produce an encrypted fmp4 which can be played by ffmpeg prior to "avformat/mov: fix frag_index.current out of sync". I'm creating a video-only stream with every single frame in its own segment, single traf/trun, nothing fancy. Here's an example (-decryption_key abcdef0123456789aabbccddeeff0011): <removed>

Last edited 19 months ago by Vitaly Ivanov (previous) (diff)

comment:11 by Balling, 19 months ago

There is no workaround possible. This is cryptography.

comment:12 by svnpenn, 19 months ago

@Vitaly Ivanov contact me, info in my bio here https://github.com/89z

Note: See TracTickets for help on using tickets.