9

When converting a WMV file to an MP4 file, it says

[mp4 @ 0x989c160] track 1: could not find tag, codec not currently supported in container

and

Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted.

But converting the WMV file to an MKV file is fine. Wonder why?

Following are the outputs of both cases.

Converting from the wmv file to a mp4 file is not working

$ ffmpeg -i "1.wmv" -c:v libx264 -crf 23 -c:a copy  "1.mp4" 
ffmpeg version git-2012-06-03-169dae8 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jun  3 2012 09:14:54 with gcc 4.6.3
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab
  libavutil      51. 56.100 / 51. 56.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.101 / 54.  6.101
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, asf, from '1.wmv':
  Metadata:
    WMFSDKVersion   : 9.00.00.3267
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
  Duration: 01:40:50.70, start: 0.000000, bitrate: 2100 kb/s
    Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, s16, 128 kb/s
    Stream #0:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 640x480, 1974 kb/s, 29.97 tbr, 1k tbn, 1k tbc
[buffer @ 0x98c28c0] w:640 h:480 pixfmt:yuv420p tb:1/1000 sar:0/1 sws_param:flags=2
[buffersink @ 0x9894320] No opaque field provided
[libx264 @ 0x98b0ec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0x98b0ec0] profile High, level 3.0
[libx264 @ 0x98b0ec0] 264 - core 125 r2200 999b753 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x989c160] track 1: could not find tag, codec not currently supported in container
Output #0, mp4, to '1.mp4':
  Metadata:
    WMFSDKVersion   : 9.00.00.3267
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    encoder         : Lavf54.6.101
    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 640x480, q=-1--1, 30k tbn, 29.97 tbc
    Stream #0:1(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, 128 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (wmv3 -> libx264)
  Stream #0:0 -> #0:1 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted

Converting from the wmv file to a mkv file is fine:

$ ffmpeg -i "1.wmv" -c:v libx264 -crf 23 -c:a copy  "1.mkv" 
ffmpeg version git-2012-06-03-169dae8 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jun  3 2012 09:14:54 with gcc 4.6.3
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab
  libavutil      51. 56.100 / 51. 56.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.101 / 54.  6.101
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, asf, from '1.wmv':
  Metadata:
    WMFSDKVersion   : 9.00.00.3267
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
  Duration: 01:40:50.70, start: 0.000000, bitrate: 2100 kb/s
    Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, s16, 128 kb/s
    Stream #0:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 640x480, 1974 kb/s, 29.97 tbr, 1k tbn, 1k tbc
File '1.mkv' already exists. Overwrite ? [y/N] y
w:640 h:480 pixfmt:yuv420p tb:1/1000 sar:0/1 sws_param:flags=2
[buffersink @ 0xa0a2760] No opaque field provided
[libx264 @ 0xa0b6ec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0xa0b6ec0] profile High, level 3.0
[libx264 @ 0xa0b6ec0] 264 - core 125 r2200 999b753 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to '1.mkv':
  Metadata:
    WMFSDKVersion   : 9.00.00.3267
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    encoder         : Lavf54.6.101
    Stream #0:0(eng): Video: h264, yuv420p, 640x480, q=-1--1, 1k tbn, 29.97 tbc
    Stream #0:1(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, 128 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (wmv3 -> libx264)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  325 fps=106 q=29.0 size=     411kB time=00:00:09.20 bitrate= 366.0kbits/s    
slhck
  • 223,558
  • 70
  • 607
  • 592
Tim
  • 16,963
  • 69
  • 181
  • 260

3 Answers3

10

codec not currently supported in container

That's your error.

Try specifying another audio codec like with -c:a aac. MP4 doesn't take Windows Media Audio in its container. You have to choose a matching audio codec, like AAC. Right now all you do is try to copy the bitstream, and that fails – as indicated by the error message.

The same problem of non-matching codecs goes for other containers, although MKV is way more open to other codecs than MP4 is, therefore you can use almost any codecs within an MKV container. This does not work for MP4.

In general though, for maximum compatibility, try to stick to the most common formats for containers, e.g.

  • AVI: MPEG-4 video, MP3 audio
  • WMV: Windows Media Video and Audio
  • MKV, MOV, MP4: h.264, AAC audio (although MKV really takes anything, here the limitation is on the playback device side)
slhck
  • 223,558
  • 70
  • 607
  • 592
  • Thanks! (1) HOw do you know it is for audio codec not video codec? (2) if specify `-c:a libfaac`, what bitrate is recommended for it? – Tim Jun 04 '12 at 11:14
  • As for bitrate, use whatever you like. I'm sure `-b:a 192k` should be enough. – slhck Jun 04 '12 at 11:18
  • @Tim: yes, it is the audiocodec, that is wrong for the mp4-container: see here http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/movenc.c;h=54deef4177262e4da943f6b306c01fbff1a9d29f;hb=HEAD#l3475 and libavformat starts counting at 0 for the tracks http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/movenc.c;h=54deef4177262e4da943f6b306c01fbff1a9d29f;hb=HEAD#l3230 – akira Jun 04 '12 at 11:22
  • @akira: Thanks! (1) How do you know it is not video codec? (2) You mean me to see `.audio_codec = CODEC_ID_AAC,` in your first link? WHat does it say for my questions? – Tim Jun 04 '12 at 11:25
  • 1
    @Tim: 1) because both link refer to the TRUTH .. aka the code. the first link setup what ffmpeg accepts for codecs for the mp4-container: aac for audio and either libx264 or ffmpeg-mpeg4 for video. the second link shows you the place of the code that generates the error-message your are seeing, scroll a few lines back and you see how ffmpeg starts counting at 0. since your are using libx264 as the video-codec and thus fullfill the requirement for the video-codec the only logical conclusion left is: you are using the wrong audio-codec (wma2 in your case instead of aac) – akira Jun 04 '12 at 11:33
  • you can also see how ffmpeg/avconv (new name) which tracks are what in the output-container: `Stream mapping: Stream #0:1 -> #0:0 (wmv3 -> libx264) Stream #0:0 -> #0:1 (copy)` ... #0:1 .. that is the track 1, the 0-track is the video-track. – akira Jun 04 '12 at 11:45
  • @akira: Are you saying avconv is a supersede of ffmpeg? So ffmpeg is no longer under development? – Tim Jun 04 '12 at 12:59
  • @Tim No, that's not true. Libav (which has the `avconv` binary) is just a fork. They more or less share the same code. FFmpeg is still under active development. – slhck Jun 04 '12 at 13:20
  • @Tim: no, i didn't say that. it's just that 'avconv' is a rewritten 'version' of the 'ffmpeg'-tool itself, under the (forked from the 'ffmpeg'-project') umbrella of 'libav'. but completely irrelevant to your problem, accept slhck's answer because it _is_ the answer. – akira Jun 04 '12 at 13:50
  • @slhck: i would take "mkv" out of your "common codecs" section, mkv just eats everything. "webm" would fit better there and "mov" and "mp4" are correct, imho. but "mkv" just eats everything. – akira Jun 04 '12 at 13:52
  • @akira: What does ""mkv" just eats everything" mean? – Tim Jun 04 '12 at 14:49
  • @slhck: After I finish converting the wmv file to kmv file, can I convert it to mp4 by `ffmpeg -i 1.kmv -c:v copy -c:a libfaac -b:a 192k 1.mp4`? Is it much faster because there is no decoding and coding for the video part, and only there is for the audio part? – Tim Jun 04 '12 at 14:58
  • @Tim Exactly – if you copy the video stream, you won't encode, therefore the command is much faster. And yes, MKV will be able to use *any* codec you feed to it, not like MP4 which has lots restrictions. See: [Comparison of container formats](http://en.wikipedia.org/wiki/Comparison_of_container_formats) – slhck Jun 04 '12 at 14:59
  • @Tim: if you want to end up with a valid `.mp4` then it is **not** faster to encode the video and audio in seperate steps. just do everything in one step: `ffmpeg -i input.wmv -c:v libx264 -crf 23 -c:a libfaac -b:a 192k out.mp4`. end of story. the chatter about what you can store inside a `.mkv` is irrelevant for your problem when you want to end up with a valid `.mp4`. – akira Jun 04 '12 at 15:12
  • @LordNeckbeard: Does `-q:a` mean the quality of audio? What does `-q:a 100` mean? THanks! – Tim Jun 04 '12 at 17:15
3

try just doing:

ffmpeg -y -i 1.wmv -b:v 2000k 1.mp4

ffmpeg should automatically pick the most appropriate audio format and use libx264 for the video, the 2000k is essentially telling it to encode at the same bitrate as the original video file.

Justin Buser
  • 1,237
  • 11
  • 14
  • Actually, by default ffmpeg uses MPEG4 for video in an MP4, so you'd have to specify `-c:v libx264` – evilsoup Apr 16 '13 at 14:35
0

Docker

I have similar problem with .wma (audio files) to .mp4 conversion (video with static image) and upload result to youtube - I will left working docker solution for future reades.

version: '3.7'

services:
    convert:
        image: jrottenberg/ffmpeg
        volumes:
            - ./mp3:/data
        
        # for WMV
        command: ' -loop 1 -framerate 2 -i "/data/image.jpeg" -i "/data/myAudio.WMA" -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a aac -b:a 128k -shortest -pix_fmt yuv420p "/data/myVideoForYT.mp4" -stats'

        # for .mp3
        #command: ' -loop 1 -framerate 2 -i "/data/image.jpeg" -i "/data/myAudio.mp3" -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p "/data/myVideoForYT.mp4" -stats'

Save below code inside docker-composer.yml file, I assume that mp3 directory (with myAudio.wma file) will be in same directory. And run it by docker compose run convert.