2

This answer had not helped: Convert compressed swf to mp4, trying to convert swf file.

ffmpeg output:

$ ffmpeg -i GTDS_demo_new.swf GTDS_demo_new.mp4
ffmpeg version 2.8.6-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.1 (Ubuntu 5.3.1-11ubuntu1) 20160311
  configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[swf @ 0x21cd1e0] Could not find codec parameters for stream 1 (Video: none, none): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, swf, from 'GTDS_demo_new.swf':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p, 64 kb/s
    Stream #0:1: Video: none, none, 12 fps, 12 tbr, 12 tbn
File 'GTDS_demo_new.mp4' already exists. Overwrite ? [y/N] y
No decoder for stream #0:1, filtering impossible
Error opening filters!

Splitting with dump-gnash also does not help: get sound without video after ffmpeg (this answer: https://stackoverflow.com/a/21023110/630169)

Community
  • 1
  • 1
Aleksey Kontsevich
  • 4,671
  • 4
  • 46
  • 101

1 Answers1

5

This bash script helped me:

#!/bin/bash

SWFFILE=$1
MP4FILE=${SWFFILE%.*}.mp4
TMPFILE=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).bin
TMPWAV=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).wav
TMPMP4=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).mp4

# create raw-dump
GNASHCMD="dump-gnash -1 -r 3 -v -D $TMPFILE -A $TMPWAV $SWFFILE"
OUTPUT="$(exec $GNASHCMD)"

# extract parameters
WIDTH="$(echo $OUTPUT | grep -o 'WIDTH=[^, }]*' | sed 's/^.*=//')"
HEIGHT="$(echo $OUTPUT | grep -o 'HEIGHT=[^, }]*' | sed 's/^.*=//')"
FPS="$(echo $OUTPUT | grep -o 'FPS_ACTUAL=[^, }]*' | sed 's/^.*=//')"

# create raw, uncompressed mp4 file
mplayer $TMPFILE -vo yuv4mpeg:file=$TMPMP4 -demuxer rawvideo -rawvideo fps=$FPS:w=$WIDTH:h=$HEIGHT:format=bgra

# create compressed mp4 with ffmpeg
ffmpeg -i $TMPMP4 -i $TMPWAV $MP4FILE

# clean up
rm -rf $TMPFILE
rm -rf $TMPMP4
rm -rf $TMPWAV

Note. Modified from that answer: https://stackoverflow.com/a/39294151/630169

Community
  • 1
  • 1
Aleksey Kontsevich
  • 4,671
  • 4
  • 46
  • 101
  • I tried your solution, but sometimes, the process gets stuck. I think it enters in an infinite loop while decompiling using gnash. Also, my SWF file size is at max 2MB, however, the raw .bin file size, which is generated, sometimes, when the program enters an infinite loop, it generates over 160GB of .bin file size. Do you have some other solution, please? It would be really helpful. Thanks – Atish Agrawal Aug 26 '19 at 14:42
  • @AtishAgrawal, no, sorry. – Aleksey Kontsevich Aug 26 '19 at 16:25
  • I added these 2 lines to the script, right below `ffmpeg -i $TMPMP4 -i $TMPWAV $MP4FILE` but above `# clean up`: the first line that I added was `# copy the timestamp of the original swf file to the output mp4` and the second one was `touch -r $SWFFILE $MP4FILE` so the **resulting MP4 file** will have the **same timestamp (date and time of creation) of the original SWF file**. If you also want to copy the SWF file's permissions (read, write and execution permissions for the SWF file's owner, group, and others), add this third line: `chmod --reference=$SWFFILE $MP4FILE` and that's it. – Yuri Sucupira Nov 21 '19 at 08:12