• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






旷野轻尘一个人 软件开发

delphi blender lazarus 网络推广 游戏开发 18710517694
 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

https://sourceforge.net/p/castle-engine/discussion/general/thread/6888149c/ 明确设置了path 目录,但是还是提示找不到。的原因以及解决方法

  • Anonymous

    Anonymous - 2013-09-17
     
    osx  关于环境变量设置了。 但是仍然找不到 相关目录的问题根本原因。   真是坑啊。 lazarus  明确设置了path 目录,但是还是提示找不到。的原因以及解决方法 

    I am trying to use view3dscene to view my x3d models on a mac. It seems like by far the x3d viewer around!
    However, many of my models have videos. I have therefore installed ffmpeg. However, view3dscene still doesn't seem to find ffmpeg.

    I can see that ffmpeg is installed: I see it in the /user library.
    In the terminal, "ffmpeg -version" returns: "ffmpeg version 2.0.1"
    I have also controlled the $PATH.
    "echo $PATH" returns "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin" ffmpeg is in /usr/local/bin

    Does anyone know how to troubleshoot this further?
    Thanks!
    Robert

     
    • Michalis Kamburelis

      Michalis Kamburelis - 2013-09-17
       

      view3dscene looks for ffmpeg on $PATH, so you're on the right track :)

      The reason why it doesn't work for you is that on Mac OS X, GUI programs run by double-clicking in Finder (or Dock, or other similar methods) do not get normal environment variables. That is, even if your $PATH within the terminal (bash) seems Ok, it is not passed like this to GUI programs (like view3dscene and all other GUI programs).

      The correct way to set $PATH for GUI programs on Mac OS X depends on Mac OS X version:

      1. The best way seems to be /etc/launchd.conf , see http://serverfault.com/questions/16355/how-to-set-global-path-on-os-x/277034#277034 , but only on Mac OS X >= 10.8

      2. On older Mac OS X you can do it by ~/.MacOSX/environment.plist , see http://www.astro.washington.edu/users/rowen/AquaEnvVar.html and https://developer.apple.com/legacy/library/qa/qa1067/_index.html (note that it may not work on newer Mac OS X versions...)

      As a workaround, you can also run viewd3scene from the console. Like

      cd directory-where-you-installed-view3dscene/
      ./view3dscene.app/Contents/MacOS/view3dscene
      

      If you run view3dscene like this, it will get all the normal environment variables, so it will see $PATH exactly as "echo $PATH" in terminal shows.

       
  • Anonymous

    Anonymous - 2013-09-17
     

    Thanks for your quick and detailed response!

    I'm not a developer and consequently am working a bit in the blind. I have still not succeeded in getting the videos to work in the scene. Hopefully though, I'm a little closer.

    I have looked at both of the links that you attached.

    I am using OS 10.6.8. So I'm trying with the .plist file.

    I took the example in the first link and substituted PYTHON for FFMPEG and my path. I then saved the file. I then opened it in the Property List Editor and it looks just like the example in the second link.

    Here is the text:

    <plist version="1.0"> <dict> <key>DISPLAY</key> <string>:0.0</string> <key>FFMPEGPATH</key> <string>/.usr/local/bin:</string> </dict> </plist>

    I restarted by computer. Upon restarting it, I tried opening the file in the Finder. I still get the same $PATH error message.

    I also tried opening the file via the console. This time, view3dscene finds ffmpeg as you said it would. However, for some reason, it still can't open my videos.

    Here is an example of the error message that I receive, which to me is completely baffling.

    view3dscene: Video warning: Error Exception when loading video from URL "file:///Users/name/Desktop/Data/Autres/Fear/Eventi/PopCorner%20Maggio%202013/Location/Allestimento%20Modello/files/TV%20Disturbo.avi": First video image "/var/folders/QO/QOwih-AyGuW89Vvdo35ELU+++TI/-Tmp-/view3dscene00000.tmp_1757351304_1.png" not found, cannot load the video

    Just for further reference, I have successfully opened the file with videos running in BS Contact and Instant Reality on a PC and with Instant Reality on the MAC. So I know that the videos and the X3D file should be fine.

    Thanks very much for your help!

     
    • Michalis Kamburelis

      Michalis Kamburelis - 2013-09-17
       

      DISPLAY :0.0 FFMPEGPATH /.usr/local/bin:

      Looks like your post got a little mangled. This ticket system allows to write wiki-like text (click on "Formatting Help" to see details, and check "Preview" before posting to be sure), unfortunately it sometimes destroys the content. It's best to surround a verbatim text (like a text file pasted) with lines of tildes, to make it look good and readable :)

      So, I cannot see how your ~/.MacOSX/environment.plist really looks like.

      Anyway, I think I can help anyway:

      I remembered struggling with it myself on the same Mac OS X version, 10.6.8. Digging in my old notes, I found a solution, inspired by this thread: http://stackoverflow.com/questions/6770411/mac-os-x-lion-no-longer-recognizes-environment-plist . It looks like Apple changed ~/.MacOSX/environment.plist file at some point, and forces it to be a binary file prepared in a special way. The solution to make your normal $PATH visible to GUI programs is to execute these lines in the console:

      rm -f ~/.MacOSX/environment.plist # clear your previous text ~/.MacOSX/environment.plist
      eval `/usr/libexec/path_helper -s`
      defaults write $HOME/.MacOSX/environment PATH "$PATH"
      

      At the end, this will give you a binary ~/.MacOSX/environment.plist file, that should allow GUI applications to see the same $PATH contents as in the terminal.

      view3dscene: Video warning: Error Exception when loading video from URL

      This error message means that view3dscene doesn't see the images produced by ffmpeg. What messages were displayed before that? You should see something like this on the console:

      FFMpeg found, executing...
      /usr/bin/ffmpeg -i "/home/michal/sources/castle-engine/trunk/demo_models/movie_texture/test_video.avi" -y -qscale 1 -f image2 "/tmp/view3dscene00000.tmp_1132265976_%d.png"
      ffmpeg version 0.8.7-6:0.8.7-1, Copyright (c) 2000-2013 the Libav developers
        built on May 20 2013 11:45:37 with gcc 4.7.3
      ................
      Input #0, mpeg, from '/home/michal/sources/castle-engine/trunk/demo_models/movie_texture/test_video.avi':
        Duration: 00:00:03.96, start: 0.500000, bitrate: 372 kb/s
          Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 256x256 [PAR 1:1 DAR 1:1], 14000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
      ................
      Stream mapping:
        Stream #0.0 -> #0.0
      ................
      

      (With the paths and versions probably different.) Can you capture your output and paste or attach it here? (You should be able to attach files when posting on forum, alternatively you can create a bug ticket from https://sourceforge.net/p/castle-engine/tickets/ and attach it there.)

      You can copy-paste view3dscene+ffmpeg output from the terminal, or (more comfortably) you can capture the output by running view3dscene from terminal like this:

      cd directory-where-you-installed-view3dscene/
      ./view3dscene.app/Contents/MacOS/view3dscene > log.txt 2>&1
      

      At the end, this will give you log.txt file with everything that was send to the console. If you can attach it here, that would be most helpful :)

       
  • Michalis Kamburelis

    Michalis Kamburelis - 2013-09-17
     

    I forgot to mention: we do plan to make handling movies more comfortable in the future. We want to do it by integrating ffmpeg (as a library) directly inside view3dscene in the future.

    This would avoid this whole trouble, you would not need to care about installing ffmpeg, configuring $PATH and so on, reading/writing movies would "just work". There just wasn't time to implement it yet :)

     
  • Anonymous

    Anonymous - 2013-09-18
     

    I was wondering why movie handling wasn't more fluid and thought that you'd probably hadn't yet had time to implement it. Just about everything else in view3dscene works so much better that the other X3D readers that it was virtually unimaginable! I'm looking forward to the improvement! :)

    Sorry that the .plist file contents didn't make it onto my post. I should have previewed it before posting. In any event, your solution worked. The .plist file is now binary. After restarting the computer, I can see that view3dscene now finds ffmpeg from the gui! So there's progress!

    However, I of course still have the additional issue where view3dscene doesn't see the images produced by ffmpeg. Here is a complete example of the output:

    view3dscene: VRML/X3D warning: Missing X3D version number, assuming 3.2
    FFMpeg found, executing...
    /usr/local/bin/ffmpeg -i "/Users/name/Desktop/Data/Autres/Fear/Eventi/PopCorner Maggio 2013/Location/Allestimento Modello/files/Ragno.avi" -y -sameq -f image2 "/var/folders/QO/QOwih-AyGuW89Vvdo35ELU+++TI/-Tmp-/view3dscene00000.tmp_962519260_%d.png"
    ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
    built on Sep 17 2013 17:02:25 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
    libavutil 52. 18.100 / 52. 18.100
    libavcodec 54. 92.100 / 54. 92.100
    libavformat 54. 63.104 / 54. 63.104
    libavdevice 54. 3.103 / 54. 3.103
    libavfilter 3. 42.103 / 3. 42.103
    libswscale 2. 2.100 / 2. 2.100
    libswresample 0. 17.102 / 0. 17.102
    libpostproc 52. 2.100 / 52. 2.100
    Option 'sameq' was removed. If you are looking for an option to preserve the quality (which is not what -sameq was for), use -qscale 0 or an equivalent quality factor option.
    Failed to set value '1' for option 'sameq'
    Error parsing global options: Invalid argument
    view3dscene: Video warning: Error Exception when loading video from URL "file:///Users/name/Desktop/Data/Autres/Fear/Eventi/PopCorner%20Maggio%202013/Location/Allestimento%20Modello/files/Ragno.avi": First video image "/var/folders/QO/QOwih-AyGuW89Vvdo35ELU+++TI/-Tmp-/view3dscene00000.tmp_962519260_1.png" not found, cannot load the video

    Thanks again for your help!

     
  • Michalis Kamburelis

    Michalis Kamburelis - 2013-09-18
     

    Thanks for the good words about view3dscene, I'm glad you like it :)

    The problem is caused by these 2 lines from ffmpeg:

    Option 'sameq' was removed. If you are looking for an option to preserve the quality (which is not what -sameq was for), use -qscale 0 or an equivalent quality factor option.
    Failed to set value '1' for option 'sameq'

    New ffmpeg versions refuse to handle -sameq option. And view3dscene 3.13.0 does use that option. This was already fixed, about a month ago --- unfortunately the fix didn't make it into view3dscene 3.13.0 release. Sorry, I should have realized sooner that this may be the cause of problems.

    I compiled a snapshot version of view3dscene for Mac OS X (compiled from today's SVN, that is: this is work-in-progress, but still it should be quite stable now). Get it from http://michalis.ii.uni.wroc.pl/castle-engine-snapshots/2013-09-18-macosx/ . This should work perfectly :)

     
  • Anonymous

    Anonymous - 2013-09-18
     

    It works a bit better now, but unfortunately there are still problems. I checked the WIP version of view3dscene with several x3d files, one without videos, one with, and a second one with videos (the one I am trying to work with). The first two loaded. So, I can see that this new version is loading videos with ffmpeg.

    The second files though crashes when loading the first video. Here are the messages from the console:

    FFMpeg found, executing...
    /usr/local/bin/ffmpeg -i "/Users/name/Desktop/Data/Autres/Fear/Eventi/PopCorner Maggio 2013/Location/Allestimento Modello/files/Ragno.avi" -y -qscale 1 -f image2 "/var/folders/QO/QOwih-AyGuW89Vvdo35ELU+++TI/-Tmp-/view3dscene00000.tmp_191386241_%d.png"
    ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
    built on Sep 17 2013 17:02:25 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
    libavutil 52. 18.100 / 52. 18.100
    libavcodec 54. 92.100 / 54. 92.100
    libavformat 54. 63.104 / 54. 63.104
    libavdevice 54. 3.103 / 54. 3.103
    libavfilter 3. 42.103 / 3. 42.103
    libswscale 2. 2.100 / 2. 2.100
    libswresample 0. 17.102 / 0. 17.102
    libpostproc 52. 2.100 / 52. 2.100
    Input #0, avi, from '/Users/name/Desktop/Data/Autres/Fear/Eventi/PopCorner Maggio 2013/Location/Allestimento Modello/files/Ragno.avi':
    Duration: 00:02:04.49, start: 0.000000, bitrate: 1624 kb/s
    Stream #0:0: Video: cinepak (cvid / 0x64697663), rgb24, 480x360, 29.97 tbr, 29.97 tbn, 29.97 tbc
    Please use -q:a or -q:v, -qscale is ambiguous
    Output #0, image2, to '/var/folders/QO/QOwih-AyGuW89Vvdo35ELU+++TI/-Tmp-/view3dscene00000.tmp_191386241_%d.png':
    Metadata:
    encoder : Lavf54.63.104
    Stream #0:0: Video: png, rgb24, 480x360, q=2-31, 200 kb/s, 90k tbn, 29.97 tbc
    Stream mapping:
    Stream #0:0 -> #0:0 (cinepak -> png)
    Press [q] to stop, [?] for help
    frame= 3731 fps=145 q=0.0 Lsize=N/A time=00:02:04.49 bitrate=N/A 
    video:148895kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.000014%
    view3dscene(11078,0xa0b20540) malloc: mmap(size=786432) failed (error code=12)
    error: can't allocate region
    set a breakpoint in malloc_error_break to debug
    view3dscene(11078,0xa0b20540) malloc: 
    mmap(size=786432) failed (error code=12)
    error: can't allocate region
    set a breakpoint in malloc_error_break to debug
    view3dscene: Exception EAccessViolation : 
    Access violation
    view3dscene: Exception EAccessViolation : 
    Access violation

     
  • Michalis Kamburelis

    Michalis Kamburelis - 2013-09-18
     

    view3dscene(11078,0xa0b20540) malloc: mmap(size=786432) failed (error code=12)

    Hm, that's a weird bug, it looks like the memory allocation failed for some reason --- either in view3dscene or a library it uses.

    Can you make a test to eliminate ffmpeg from the equation first?

    1.Convert your movie to a sequence of images first, by running ffmpeg like this:

    mkdir ~/test_images/
    /usr/local/bin/ffmpeg -i "/Users/name/Desktop/Data/Autres/Fear/Eventi/PopCorner Maggio 2013/Location/Allestimento Modello/files/Ragno.avi" -y -qscale 1 -f image2 ~/test_images/image_%d.png
    

    If this succeeds, you should see the directory ~/test_images/ full of png images.

    2.Then change your X3D file: look for the MovieTexture node, and when the url says ".../Ragno.avi" change it to ".../image_@counter(1).png" (with proper path, relative from the X3D file, or absolute). This is how you can load a movie from an image sequence in view3dscene (see http://castle-engine.sourceforge.net/x3d_extensions.php#section_ext_movie_from_image_sequence ).

    And then try opening the X3D with view3dscene. Does it still fail?

    If view3dscene still does fail, I'll probably need to see the actual X3D file and/or the movie file to reproduce the bug and fix it. Is that possible? Can you send (attach to this forum post, or create a ticket on https://sourceforge.net/p/castle-engine/tickets/ ) me the X3D + movie file? If you don't want to share it publicly but you're Ok with showing it to me privately (I would only use it for the purpose of investigating this bug, of course), you could also send it to me through private email (http://castle-engine.sourceforge.net/forum.php contains my email, "...send email to Michalis Kamburelis.").

      
    Last edit: Michalis Kamburelis 2013-09-18
  • Anonymous

    Anonymous - 2013-09-19
     

    I'm not surprised that it has something to do with memory. I've noticed that as soon as I add a movie, X3d scenes take a lot longer to load and respond slower once loaded. The scene with videos that I did succeed in loading took longer to load than I've ever seen. However, unlike other X3d readers, view3dscene responded fluidly once loaded. Another plus for viewx3dscene!
    I might add that for that reason, the video in my scenes are prepared at a low bid rate and fps and the scenes themselves are set so that the videos play only when they are in view.
    Anyway, I converted the movie to a sequences of images. This worked.
    Then I changed the X3d file. When I tried to open the scene, view3dscene just closes without loading the scene (after a while). I did this in the Console with the same result. However, this time it strangely doesn't produce anything in the log.
    I can send you the scene and the movie file. However, I would prefer not to upload them to a publicly viewable spot. I have a difficulty via e-mail as well because the two files exceed my e-mail size limit (even compressed.) The model is 25 mb and the video 20. Would it be possible to send you the files another way such as via Dropbox?

     
    • Michalis Kamburelis

      Michalis Kamburelis - 2013-09-19
       

      The scene with videos that I did succeed in loading took longer to load than I've ever seen. However, unlike other X3d readers, view3dscene responded fluidly once loaded. Another plus for viewx3dscene!

      This is all as expected. See http://castle-engine.sourceforge.net/x3d_implementation_texturing.php for the notes about MovieTexture. We (at least for now) do not read/play movie with streaming, instead we just read and keep whole movie in memory. This is very fast to render (almost as fast as normal textures), but very slow and memory-consuming to load.

      Also, when loading a movie, we always load it as 25-frames per second, and it's uncompressed in memory. So your optimizations (low bit rate and fps) don't help, the movie is still huge in the memory (both normal memory and the GPU memory). The only things that decrease memory consumption is shorter movie time or smaller resolution.

      We do want to improve it eventually, of course. When we'll implementing playing movies with streaming, it will be decompressed on the fly, and loading will be fast and not memory-hungry. OTOH, the rendering may then be slower (as the CPU will be busy decompressing the movie, while you try to operate the scene). But it will be acceptable on fast computers, especially if movie has low FPS and bitrate, like yours.

      We will probably always keep the current handling of movies (load as a whole) as an option (maybe automatically detected based on the movie size). Current approach is quite perfect when you use movies that are only a couple of seconds long, very useful for various game effects.

      OK, solution for now (before we implement streamed playback and better ffmpeg integration): I think it is better to be safe, and admit that we cannot deal with large movies, than to eat all the system memory and crash. So lets' not try to load long movies. I implemented this now: we only load the first 1 minute of a movie. This equals 1500 frames with 25 fps. It can still eat a lof of memory, but modern computers (with > 1 GB of RAM) should survive :)

      As for the unclear error messages: I was testing, and when we literally run out of memory, in some cases indeed messages are a lttle strange, because there isn't even enough memory to construct suitable error messages... I'll see about improving that.

      I can send you the scene and the movie file

      Looks like it's not necessary. If your movie is large, then the mystery is solved, and it's unfortunately just a consequence of our unoptimal movie handling. Sorry for that, but there's no immediate fix available --- we did plan to improve this anyway, it's just not trivial.

      How long is your movie (in seconds) and what is the resolution (width, height in pixels)?

       
    • Anonymous

      Anonymous - 2013-09-20
       

      1) Ragno.avi = length 2'04", 480 x 360 pixels, FPS 24, data rate 1,313 kbit/s

      already this causes the problem

      2) Sparo.avi = length 2'56", 1172 x 878 pixels, FPS 24, data rate 4,316 kbit/s

      3) TV Disturbo.avi = length, 2' 29", 729 x 540 pixels, FPS 24, data rate 1,533 kbits/s

      So, none of the files are really very long or large. I wrote that I successfully loaded another x3d world with videos. Those videos I was able to reduce to 10-20 seconds. All of the other details are comparable. I have also reduced the length of the videos in the one that I am working on now, but can not do so more than I have i.e. the 2 minute range. In any event, that probably explains the source of the problem.

       
      • Michalis Kamburelis

        Michalis Kamburelis - 2013-09-28
         

        Given the fact that we naively load the videos fully to the memory, uncompressed (both RAM and GPU memory), the sizes are actually quite large:

        1) 480 * 360 * 3 (24-bit RGB) * 25 (always 25 FPS) * 124 (seconds) = 1607040000 ~= 1.5 GB

        2) 1172 * 878 * 3 * 25 * 176 ~= 12.9 GB

        3) 729 * 540 * 3 * 25 * 149 ~= 4.1 GB

        These huge sizes of course show that our movie loading is really useless for larger videos... We could shave off some space by loading videos only to GPU (no need to keep in RAM if we only want to render them), but it will exhaust the GPU texture memory anyway.

        Oh, and for MovieTexture, the images are resized to be power-of-2, and by default we resize up, so the sizes are actually even bigger. Also, we instruct GPU to create mipmaps for them (unless you use TextureProperties and request worse minificationFilter), this also increases the size a bit.

        Sorry, the conclusion from this is just that we're not ready yet to load your videos... You'll have to wait for proper movie streaming implementation to be able to play movies reliably in view3dscene. Hope you still like view3dscene :)

delphi lazarus opengl 网页操作自动化, 图像分析破解,游戏开发
发表于 2018-02-02 08:04  旷野轻尘一个人  阅读(175)  评论(0)    收藏  举报
 
刷新页面返回顶部