Opened 5 years ago

Closed 5 years ago

#1638 closed defect (fixed)

SWF demuxer cannot correctly identify MP3 stream

Reported by: mbradshaw Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: swf
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I created a SWF file with Adobe Flash Professional CS6 today. It's a simple SWF that just contains a MP3 track. FFmpeg does not correctly read this though and is not able to identify the MP3 stream.

Below is the output from ffmpeg regarding this SWF I created today:

$ ./ffmpeg -i ~/UntitledTest.swf
ffmpeg version N-43294-g8993c25 Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 12 2012 10:15:07 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
  configuration: --enable-libx264 --enable-gpl --enable-libopenjpeg
  libavutil      51. 66.101 / 51. 66.101
  libavcodec     54. 50.100 / 54. 50.100
  libavformat    54. 22.101 / 54. 22.101
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3.  5.102 /  3.  5.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[swf @ 0x10180ec00] Could not find codec parameters for stream 0 (Audio: pcm_s16le, 5512 Hz, 1 channels, 88 kb/s): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[swf @ 0x10180ec00] Estimating duration from bitrate, this may be inaccurate
/Users/mjbshaw/UntitledTest.swf: could not find codec parameters

I decompiled the swf file with Sothink's SWF Decompiler and got the following (correct) mp3 out:

$ ./ffmpeg -i ~/Desktop/UntitledTest/sound/sound\ 1.mp3 
ffmpeg version N-43294-g8993c25 Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 12 2012 10:15:07 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
  configuration: --enable-libx264 --enable-gpl --enable-libopenjpeg
  libavutil      51. 66.101 / 51. 66.101
  libavcodec     54. 50.100 / 54. 50.100
  libavformat    54. 22.101 / 54. 22.101
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3.  5.102 /  3.  5.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[mp3 @ 0x10180ec00] max_analyze_duration 5000000 reached at 5015510
[mp3 @ 0x10180ec00] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/Users/mjbshaw/Desktop/UntitledTest/sound/sound 1.mp3':
  Duration: 00:00:55.95, start: 0.000000, bitrate: 128 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s
At least one output file must be specified

Attachments (1)

UntitledTest.swf (874.7 KB) - added by mbradshaw 5 years ago.
SWF file showing the defect.

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by mbradshaw

SWF file showing the defect.

comment:1 Changed 5 years ago by cehoyos

  • Keywords swf added
  • Reproduced by developer set
  • Status changed from new to open

comment:2 follow-up: Changed 5 years ago by mbradshaw

I've looked into this a bit and I've found the issue, but I'm unsure of how to resolve it so I'll give my analysis in the hopes that someone might know the best solution (or help me understand the best solution).

The SWF file has a TAG_STREAMHEAD2 tag, but there is no streaming audio (there are no TAG_STREAMBLOCK tags). AFAIK, this is valid, as the TAG_STREAMHEAD2 just says what format to expect streamed audio to be in, even if it's not present. The TAG_STREAMHEAD2 reports pcm_s16le, 5512 Hz, 1 channels, 88 kb/s audio, which FFmpeg correctly reads, but it struggles from there. I don't know if FFmpeg is rejecting the reported audio format, or if it's choking on the fact that there's no TAG_STREAMBLOCK tags.

Anyway, the audio is not streamed in the frames. Instead, in this file, it is found in a DefineSound? tag (tag code = 14), and the entire MP3 file is stored as part of this tag. FFmpeg does not look for any DefineSound? tags. I could easily add the necessary code to find and parse a DefineSound? tag, but I'm unsure of how to properly demux this sound because it's not broken up into frames (like audio (TAG_STREAMHEAD(2)) or video (TAG_VIDEOSTREAM) streams are). Audio in DefineSound? tags come in one solid chunk.

I could hack it, but I'd rather not write hackish code. Ideas on how to (nicely) add demuxing support for DefineSound? tags are very welcome!

comment:3 in reply to: ↑ 2 Changed 5 years ago by michael

Replying to mbradshaw:

Anyway, the audio is not streamed in the frames. Instead, in this file, it is found in a DefineSound? tag (tag code = 14), and the entire MP3 file is stored as part of this tag. FFmpeg does not look for any DefineSound? tags. I could easily add the necessary code to find and parse a DefineSound? tag, but I'm unsure of how to properly demux this sound because it's not broken up into frames (like audio (TAG_STREAMHEAD(2)) or video (TAG_VIDEOSTREAM) streams are). Audio in DefineSound? tags come in one solid chunk.

You can return randomly (or fixed) sized chunks from the mp3 and set AVStream->need_parsing appropriately then libavformat will break things into chunks for you

comment:4 Changed 5 years ago by mbradshaw

  • Resolution set to fixed
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.