7

Briefing

I have some .wmv files (actually, my full batch file deals with multiple filetypes) with weird data streams that are needed for an external program to recognize them.

I'm trying to remove every stream that is not data or audio, which also needs to be reencoded.

My current command is

fmpeg -y -loglevel debug -flags global_header -err_detect ignore_err -fflags +igndts -copy_unknown -i "%%~fV" -f !ext! -c copy -map 0 -vn -sn -b:a 32k "%%~pnxV.tmpoutput"

Which works for other file types with the same type of data stream and will work with .wmv if I add -dn (even though my file is then not recognizable by the external program). The command above, as is, for .wmv files will output the error Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted.

From FFprobe (full output below), I can see the message Unsupported codec with id 0 for input stream 2, so I believe it's beyond doubt that the cause is indeed the data stream.


Question

The thing is that I expected -copy_unknown to deal with this and it doesn't. My question is: how do I copy this unsupported, not used anywhere else data stream? Are there other ways to approach the matter?

Thanks


Extra info

Full FFmpeg output (with -loglevel debug):

ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-flags' ... matched as AVOption 'flags' with argument 'global_header'.
Reading option '-err_detect' ...Routing option err_detect to both codec and muxer layer
 matched as AVOption 'err_detect' with argument 'ignore_err'.
Reading option '-fflags' ... matched as AVOption 'fflags' with argument '+igndts'.
Reading option '-copy_unknown' ... matched as option 'copy_unknown' (Copy unknown stream types) with argument '1'.
Reading option '-i' ... matched as input url with argument 'C:\Users\Fabio\Desktop\Testes\test\a.wmv'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'asf'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0'.
Reading option '-vn' ... matched as option 'vn' (disable video) with argument '1'.
Reading option '-sn' ... matched as option 'sn' (disable subtitle) with argument '1'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '32k'.
Reading option '\Users\Fabio\Desktop\Testes\test\a.wmv.tmpoutput' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option copy_unknown (Copy unknown stream types) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url C:\Users\Fabio\Desktop\Testes\test\a.wmv.
Successfully parsed a group of options.
Opening an input file: C:\Users\Fabio\Desktop\Testes\test\a.wmv.
[NULL @ 0000025955e7af40] Opening 'C:\Users\Fabio\Desktop\Testes\test\a.wmv' for reading
[file @ 0000025955e7b740] Setting default whitelist 'file,crypto'
[asf @ 0000025955e7af40] Format asf probed with size=2048 and score=100
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=244
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=26
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=3295
[asf @ 0000025955e7af40] Payload extension 50 2
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=42
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=44
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=834
[asf @ 0000025955e7af40] Before avformat_find_stream_info() pos: 5793 bytes read:32768 seeks:0 nb_streams:3
[asf @ 0000025955e7af40] parser not found for codec wmav2, packets or times may be invalid.
[wmv3 @ 0000025955eb4480] Header: 46690A01
[wmv3 @ 0000025955eb4480] Profile 1:
frmrtq_postproc=3, bitrtq_postproc=6
LoopFilter=1, MultiRes=0, FastUVMC=0, Extended MV=0
Rangered=0, VSTransform=1, Overlap=1, SyncMarker=0
DQuant=0, Quantizer mode=0, Max B-frames=0
[wmv3 @ 0000025955eb4480] Extra data: 8 bits left, value: 0
[wmv3 @ 0000025955eb4480] Format yuv420p chosen by get_format().
    Last message repeated 1 times
[asf @ 0000025955e7af40] parser not found for codec wmav2, packets or times may be invalid.
[asf @ 0000025955e7af40] All info found
[asf @ 0000025955e7af40] After avformat_find_stream_info() pos: 191671 bytes read:196608 seeks:0 frames:58
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from 'C:\Users\Fabio\Desktop\Testes\test\a.wmv':
  Metadata:
    copyright       : ChessBase GmbH
    WMFSDKVersion   : 12.0.9600.17415
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    DeviceConformanceTemplate: MP@ML
  Duration: 00:00:23.08, start: 0.000000, bitrate: 526 kb/s
    Stream #0:0, 17, 1/1000: Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, stereo, fltp, 96 kb/s
    Stream #0:1, 41, 1/1000: Video: wmv3 (Main), 1 reference frame (WMV3 / 0x33564D57), yuv420p(left), 640x480, 0/1, 415 kb/s, 25 tbr, 1k tbn, 1k tbc
    Stream #0:2, 0, 1/1000: Data: none, 0/1, 10 kb/s
Successfully opened the file.
Parsing a group of options: output url \Users\Fabio\Desktop\Testes\test\a.wmv.tmpoutput.
Applying option f (force format) with argument asf.
Applying option c (codec name) with argument copy.
Applying option map (set input stream mapping) with argument 0.
Applying option vn (disable video) with argument 1.
Applying option sn (disable subtitle) with argument 1.
Applying option b:a (video bitrate (please use -b:v)) with argument 32k.
Successfully parsed a group of options.
Opening an output file: \Users\Fabio\Desktop\Testes\test\a.wmv.tmpoutput.
[file @ 0000025955eee200] Setting default whitelist 'file,crypto'
Successfully opened the file.
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:2 -> #0:1 (copy)
    Last message repeated 1 times
[AVIOContext @ 0000025955eee2c0] Statistics: 0 seeks, 1 writeouts
[AVIOContext @ 0000025955e83980] Statistics: 196608 bytes read, 0 seeks

FFprobe on a sample file:

ffprobe version 4.3 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200621
  configuration: --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-libopenmpt --enable-amf
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
[wmv3 @ 00000180012e1440] Extra data: 8 bits left, value: 0
Input #0, asf, from 'test/a.wmv':
  Metadata:

    WMFSDKVersion   : 12.0.9600.17415
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    DeviceConformanceTemplate: MP@ML
  Duration: 00:00:23.08, start: 0.000000, bitrate: 526 kb/s
    Stream #0:0: Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, 2 channels, fltp, 96 kb/s
    Stream #0:1: Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 640x480, 415 kb/s, 25 tbr, 1k tbn, 1k tbc
    Stream #0:2: Data: none, 10 kb/s
[wmv3 @ 0000018001324a80] Extra data: 8 bits left, value: 0
Unsupported codec with id 0 for input stream 2

Other

I chose to specify -f and .tmpoutput to facilitate other non-related parts of my flow.

1 Answer 1

0

Try:

  • Updating ffmpeg to the latest version.
  • Informing the extension name .wmv to the output file in ffmpeg.
  • mkvtoolnix to remux the files into a new .mkv container, which supports everything.
5
  • As you can see from my output, ffmpeg was up-to-date when the question was asked. Still, the new version didn't help, neither did specifying .wmv. As for mkvtoolnix, adding other tools to this flow would beat the purposes of the project, so it's a very final resort. Also, the external program needs the container to remain as .wmv. Jul 12, 2020 at 0:09
  • could it be that the stream is encrypted somehow, or has some wvm DRM attached to it. en.wikipedia.org/wiki/… Jul 13, 2020 at 22:29
  • Well, I checked for DRM and there is none... Jul 14, 2020 at 4:12
  • What is the software that is generating the .wmv files in the fisrt place?
    – Azevedo
    Jul 14, 2020 at 14:10
  • I don't know, they were not generated by me, they are part of something I purchased and want to remove the unneeded video stream for filesize purposes. When I convert the files adding -dn I do get a working video file, but it won't be recognized by the external software. Jul 15, 2020 at 2:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .