Hey guys, need a hand here. So I've been seeing that there's a lot of issue with parsing the output that ffmpeg gives out depending on the version. Already got it to tell me which codecs it supports by updating to the .dev version because everything was a no.

however when I try encoding a test file, I get this error (even though it's supported by ffmpeg)

    The file could not be transcoded because the video codec is not supported
    Command: /usr/local/bin/ffmpeg -i "/tmp/test_1.mp4" -v -1

Not sure what the issue is - gonna paste my ffmpeg info here.

ffmpeg N-31267-g4e59c8e libavutil 51. 11. 0 / 51. 11. 0 libavcodec 53. 7. 0 / 53. 7. 0 libavformat 53. 5. 0 / 53. 5. 0 libavdevice 53. 2. 0 / 53. 2. 0 libavfilter 2. 24. 3 / 2. 24. 3 libswscale 2. 0. 0 / 2. 0. 0 libpostproc 51. 2. 0 / 51. 2. 0 ffmpeg version N-31267-g4e59c8e, Copyright (c) 2000-2011 the FFmpeg developers built on Jul 6 2011 16:33:59 with gcc 4.4.3 configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab libavutil 51. 11. 0 / 51. 11. 0 libavcodec 53. 7. 0 / 53. 7. 0 libavformat 53. 5. 0 / 53. 5. 0 libavdevice 53. 2. 0 / 53. 2. 0 libavfilter 2. 24. 3 / 2. 24. 3 libswscale 2. 0. 0 / 2. 0. 0 libpostproc 51. 2. 0 / 51. 2. 0

Attached is a dump of ffmpeg -formats

Running ubuntu

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

antoniotorres’s picture

FileSize
7.79 KB

Ack, forgot the file.

antoniotorres’s picture

I don't mind downgrading to another version of ffmpeg or whatever, just trying to get this thing to encode mov's and avi's :)

arthurf’s picture

what does admin/config/ffmpeg_wrapper say about your installed codecs?

antoniotorres’s picture

FileSize
573.47 KB

Here

antoniotorres’s picture

is that what you needed?

arthurf’s picture

Can you try running the conversion you want to do on the command line and see if it works? Something like:
/usr/local/bin/ffmpeg -i "/tmp/test_1.mp4" test.flv

antoniotorres’s picture

It Worked

# /usr/local/bin/ffmpeg -i "/tmp/test_1.mp4" test.flv
ffmpeg version N-31404-ga8c2ff2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jul 11 2011 14:29:06 with gcc 4.4.3
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
  libavutil    51. 11. 0 / 51. 11. 0
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  5. 0 / 53.  5. 0
  libavdevice  53.  2. 0 / 53.  2. 0
  libavfilter   2. 24. 4 /  2. 24. 4
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  51.  2. 0 / 51.  2. 0

Seems stream 1 codec frame rate differs from container frame rate: 59.94 (20000000/333667) -> 29.97 (30000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/test_1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1qt
    creation_time   : 2011-07-11 16:27:12
    encoder         : vlc 1.1.3 stream output
    encoder-eng     : vlc 1.1.3 stream output
  Duration: 00:00:12.05, start: 0.000000, bitrate: 2613 kb/s
    Stream #0.0(eng): Audio: aac, 44100 Hz, stereo, s16, 88 kb/s
    Metadata:
      creation_time   : 2011-07-11 16:27:12
    Stream #0.1(eng): Video: h264 (High), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 2535 kb/s, 29.97 fps, 29.97 tbr, 1001 tbn, 59.94 tbc
    Metadata:
      creation_time   : 2011-07-11 16:27:12
[buffer @ 0x941b860] w:720 h:480 pixfmt:yuv420p tb:1/1000000 sar:8/9 sws_param:
Output #0, flv, to 'test.flv':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1qt
    creation_time   : 2011-07-11 16:27:12
    encoder-eng     : vlc 1.1.3 stream output
    encoder         : Lavf53.5.0
    Stream #0.0(eng): Video: flv, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 29.97 tbc
    Metadata:
      creation_time   : 2011-07-11 16:27:12
    Stream #0.1(eng): Audio: libmp3lame, 44100 Hz, stereo, s16, 64 kb/s
    Metadata:
      creation_time   : 2011-07-11 16:27:12
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
Press [q] to stop, [?] for help
frame=  357 fps= 93 q=31.0 Lsize=    1229kB time=00:00:11.97 bitrate= 840.9kbits/s dup=0 drop=1
video:1122kB audio:94kB global headers:0kB muxing overhead 1.090977%
ronin17’s picture

I'm having the same issue.

Using ffmpeg from the command line works perfectly fine, but ffmpeg_wrapper keeps giving me the "The file could not be transcoded because the video codec is not supported" error.

I'm using ffmpeg version N-31422-g45ecc7a.

arthurf’s picture

@ronin17 are codecs showing in admin/config/ffmpeg_wrapper?

antoniotorres’s picture

any word on my encoding results?

Thanks infinitely for any assistance you can provide. I can pay for your time if you help me figure this out as well.

antoniotorres’s picture

Tested latest dev version, no dice still.

arthurf’s picture

Try setting can_decode_file() to return TRUE. If that works then it is likely an issue with how the codecs are being detected.

antoniotorres’s picture

yeah it works. any way I can help patch this?

arthurf’s picture

I think I may have tracked this down to a change that I made to how ffmpeg reports back "not available". The function was checking for 'na' instead of 'N/A' which is the new way that ffmpeg returns data. Please give the dev version a try again.

osopolar’s picture

The interesting line is:

Stream #0.1(eng): Video: h264 (High), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 2535 kb/s, 29.97 fps, 29.97 tbr, 1001 tbn, 59.94 tbc

The function get_file_data($filepath) will determine a codec called "h264 (High)". But in the codec list from get_formats() will be only a codec called "h264".

I have the same problem with the codec "h264 (Main)" in my local machine (using Mac ports, ffmpeg version 0.7.1). I thought about adding the following to get_file_data():

      // Not sure if it is a bug of ffmpeg, but it showed the codec h264 (Main),
      // instead of h264, see issue on drupal.org/node/1215400.
      $video_codec_exceptions = array(
        'h264 (Main)' => 'h264',
        'h264 (High)' => 'h264',
      );
      // Set the correct codec name.
      $file['video']['codec'] = $video_codec_exceptions[$file['video']['codec']];

How much exceptions will there be? How many surprises will ffmpeg have for us? I guess I need to dive in the ffmpeg documentation.

Another way would be to fix the regex to only read the first word, because in the codec list aren't codecs with spaces.

osopolar’s picture

Added the patch for the quick workaround.

I think the best is to modify the regex, to just take the first word as codec. I saw codecs with letters and digits and underscore but nothing else, not hyphen and no space in the name.

osopolar’s picture

Status: Active » Needs work
osopolar’s picture

There are a lot of different h264 profiles: http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Profiles. Recently I got "h264 (Constrained Baseline)". Let's fix this with an regex. But I don't kow, which one to touch.

If this applies to all of them, maybe use this:

      // Ffmpeg shows the codec h264 followed by a space and the profile name in
      // parenthesis, i.e. "h264 (Main)". Extract only the codec, i.e. h264.
      // See issue on drupal.org/node/1215400.
      if (preg_match('/([^\s]+).*/', $file['video']['codec'], $matches)) {
        // Set the correct codec name.
        $file['video']['codec'] = $matches[1];
      }
arthurf’s picture

@osopolar yes I've seen this as well on recent versions of ffmpeg and accompanying libraries. I'm not sure if it is safe to assume that the text in the parentheses is safe to ignore, but I don't know if there is another choice.

I think your patch is a good idea but I think it needs to be moved up into the main if/else statement because otherwise $ffmpeg->errors is still going to be set.

osopolar’s picture

The codec is detected well, but it is named "h264 (Main)" instead of just "h264". Later we the module is comparing the name of the video codec with the codec list of ffmpeg and won't find it.

I guess there should be something written in the ffmpeg specifications, but currently I don't have time to research.

mfb’s picture

Tracking

vivek1989’s picture

how to convert wmv file