How do I encode Dirac video on OS X?

Anonymous
2010-02-05
2013-06-04

  • Anonymous
    2010-02-05

    I'm at a complete loss for how to encode videos with Dirac on Mac OS X. I've tried downloading the Schroedinger source (I have no idea how to compile it), installing Schroedinger via MacPorts (which doesn't add the command line functions, or anything I can figure out how to access), and Handbrake (which I was informed does Dirac, but I guess not), to no avail. Google is not my friend in this case.

    I'm not a programmer, I just want to encode my videos in this very promising format. Can anyone help me out?

     
  • Tommy Thorn
    Tommy Thorn
    2010-02-07

    Actually it works fine for me, but I installed ffmpeg via MacPorts. From memory, all you need is something like

      ffmpeg -i <inputfile> -f libdirac output.mp4

    There are lots of options to play with. Note, using libdirac will use the direc-research codec for encoding.

     

  • Anonymous
    2010-02-07

    Ahh, okay, ffmpeg is what I need. I thought Schroedinger would add the schro_encode command as described on the wiki, but I guess not.

    So now I just grabbed ffmpeg from MacPorts, and it says libdirac isn't a recognized output format. I remember in my frantic Googling reading that ffmpeg had to be compiled with libdirac and libschroedinger specifically, though; is that the problem? And — again, sorry for the uneducated noob question — how would I do that through MacPorts?

    Or is it something different?

     
  • Tommy Thorn
    Tommy Thorn
    2010-02-07

    My bad, it was from memory. The -f should have been -vcodec. Example:

    $ ffmpeg -i 00024.MTS -vcodec libdirac -s 480x270 00024-480x270.mp4
    FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
      configuration: --prefix=/opt/local --disable-vhook --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-avfilter-lavf --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/gcc-4.2 --arch=x86_64
      libavutil     49.15. 0 / 49.15. 0
      libavcodec    52.20. 0 / 52.20. 0
      libavformat   52.31. 0 / 52.31. 0
      libavdevice   52. 1. 0 / 52. 1. 0
      libavfilter    1. 4. 0 /  1. 4. 0
      libswscale     1. 7. 1 /  1. 7. 1
      libpostproc   51. 2. 0 / 51. 2. 0
      built on Oct 12 2009 00:52:45, gcc: 4.2.1 (Apple Inc. build 5646)
    [h264 @ 0x101812800]number of reference frames exceeds max (probably corrupt input), discarding one
        Last message repeated 11 times
    Input #0, mpegts, from '00024.MTS':
      Duration: 00:05:22.82, start: 986.967578, bitrate: 16763 kb/s
      Program 1 
        Stream #0.0[0x1011]: Video: h264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 59.94 tbr, 90k tbn, 59.94 tbc
        Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
    File '00024-480x270.mp4' already exists. Overwrite ? [y/N] y
    Output #0, mp4, to '00024-480x270.mp4':
        Stream #0.0: Video: libdirac, yuv420p, 480x270 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 59.94 tbc
        Stream #0.1: Audio: libfaac, 48000 Hz, stereo, s16, 64 kb/s
    Stream mapping:
      Stream #0.0 -> #0.0
      Stream #0.1 -> #0.1
    Press [q] to stop encoding
    frame=  204 fps=  7 q=0.0 size=     412kB time=3.25 bitrate=1037.3kbits/s
    

    You can use the Schroedinger and Dirac-research codec directly. I haven't tried the former, but the latter requests the input to be in the YUV format, so that's an extra step. Something like this worked for me:

    $ ffmpeg -i 00025.MTS -vframes 120 -s 1280x720 -f rawvideo - |dirac_encoder -verbose -cformat YUV420P -HD720P60 -fr 29.97 -qf 9 - 00025-720p-qf9.drc
    
     

  • Anonymous
    2010-02-07

    Well, I've managed to output a video which is playable in VLC and not Quicktime, and identifies as "drac" in the Inspector. Thank you very much!

    Of course, it's having trouble playing more than two frames at once (which is usually only a problem I get with completely uncompressed video), so I'm experimenting with settings to see if I can fix that. I think I can figure it out from here, but if not, I'll be sure to do the textual equivalent of flailing my arms and screaming for help again.

    Thanks again!

     

  • Anonymous
    2010-02-07

    Sorry for the double post, but I just finished another test, outputting at 1280x720 instead of 1920x1080. This noticeably improved performance, in that I can now view maybe four consecutive frames at a time.

    I'll keep tinkering, but if anyone has any insight on that issue, I'd appreciate it.

     
  • Tommy Thorn
    Tommy Thorn
    2010-02-08

    I'm not sure I understand what you mean by "two frames at once". Can you show us how you doing this?. Are you using two decoders?

    FWIW, ffplay works great and the picture looks better than in VLC (not sure why). I seem to have problems using Dirac in the Ogg container, but MPEG4 and "raw" Dirac (.drc) works great.

     

  • Anonymous
    2010-02-08

    The video will play for about two frames, then freezes. The audio continues fine, but the video doesn't. Pausing, and then moving the playhead to a later point in the video will show the frame at that point…sometimes.

    I encoded at 480x270 with no problems, so for some reason the way I'm encoding requires an excessive amount of system resources to play. VLC has played the BBC's HD Dirac samples with no problems for me, so I'm not sure what I'm doing wrong. Those used TS, not MP4, though.

     
  • Tommy Thorn
    Tommy Thorn
    2010-02-09

    Zac, you'll have to give more detail. My MacBook Pro (dual 2.4 GHz) has no problem with real-time decoding of roughly 720p and below.  Does ffplay work for you?  Can you share a transcript of how you are encoding?

     

  • Anonymous
    2010-02-09

    Here's the output of an encode I just did:

    $ ffmpeg -i /Volumes/Z7500/Final/TaranMA-Uncompressed2.mov -vcodec libdirac -b 2200000 -s 1280x720 TaranMA-Dirac.mp4
    FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
      configuration: --prefix=/opt/local --disable-vhook --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-avfilter-lavf --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/gcc-4.2 --arch=x86_64
      libavutil     49.15. 0 / 49.15. 0
      libavcodec    52.20. 0 / 52.20. 0
      libavformat   52.31. 0 / 52.31. 0
      libavdevice   52. 1. 0 / 52. 1. 0
      libavfilter    1. 4. 0 /  1. 4. 0
      libswscale     1. 7. 1 /  1. 7. 1
      libpostproc   51. 2. 0 / 51. 2. 0
      built on Feb  7 2010 03:39:54, gcc: 4.2.1 (Apple Inc. build 5646) (dot 1)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/Z7500/Final/TaranMA-Uncompressed2.mov':
      Duration: 00:00:12.00, start: 0.000000, bitrate: 1594062 kb/s
        Stream #0.0(eng): Video: rawvideo, bgr32_1, 1920x1080, 24 tbr, 24 tbn, 24 tbc
        Stream #0.1(eng): Data: tmcd / 0x64636D74
        Stream #0.2(eng): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
    File 'TaranMA-Dirac.mp4' already exists. Overwrite ? [y/N] y
    Output #0, mp4, to 'TaranMA-Dirac.mp4':
        Stream #0.0(eng): Video: libdirac, yuv420p, 1280x720, q=2-31, 2200 kb/s, 90k tbn, 24 tbc
        Stream #0.1(eng): Audio: libfaac, 48000 Hz, stereo, s16, 64 kb/s
    Stream mapping:
      Stream #0.0 -> #0.0
      Stream #0.2 -> #0.1
    Press [q] to stop encoding
    frame=    5 fps=  0 q=0.0 size=       0kB time=10000000000.00 bitrate=   0.0kbitframe=    7 fps=  6 q=0.0 size=       0kB time=10000000000.00 bitrate=   0.0kbitframe=  288 fps=  2 q=0.0 Lsize=    6707kB time=11.93 bitrate=4607.6kbits/s    
    video:6612kB audio:86kB global headers:0kB muxing overhead 0.138887%
    

    This actually performed better in VLC, probably because I encoded at 2.2 Mbps this time (my other attempts were 8 Mbps), but not by much.

    I tried ffplay, and while it did manage to display the entire video, the framerate was erratic, as if I were running a video game at too-high graphics settings. The audio finished about 2 seconds before the video did.

    Something's not right, as I also have a dual-core 2.4 GHz MBP.

     

  • Anonymous
    2010-02-11

    Oh, wow, duh. Should have thought of this before.

    I used libschroedinger instead and it works perfectly.

     
  • Tommy Thorn
    Tommy Thorn
    2010-02-11

    Care to elaborate? The implementation of the codec used for encoding should not influence (dramatically) the performance of the decoder. Did you somehow use libdirac for decoding (didn't think VLC could do that)?

    I haven't had time to reproduce your result, but obviouslyl a higher bitrate would increase the load on the decoder.

     

  • Anonymous
    2010-02-11

    Not much to elaborate on. Encoding with libdirac gave me issues, encoding with libschroedinger at the exact same settings gave me none. A libdirac-encoded file with 8 Mbps video caused both VLC and ffplay to choke, whereas a libschroedinger-encoded 8 Mbps video worked beautifully (in VLC; I didn't try it in ffplay, but I assume it would work just as well).

    I'm as baffled as you are, but I don't particularly mind success.