Changeset 381
- Timestamp:
- 05/02/08 16:38:53 (2 years ago)
- Files:
-
- trunk/uploadr/MacUploadr.app/Contents/Resources/components/Makefile (modified) (2 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/components/flGM.cpp (modified) (12 diffs)
- trunk/uploadr/README.osx (modified) (1 diff)
- trunk/uploadr/README.windows (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/uploadr/MacUploadr.app/Contents/Resources/components/Makefile
r319 r381 17 17 EXIV_INCLUDE := -I/usr/local/include/exiv2 18 18 EXIV_LIB := -L/usr/local/lib -L/usr/lib 19 FF_INCLUDE := -I/usr/local/include /ffmpeg19 FF_INCLUDE := -I/usr/local/include 20 20 FF_LIB := -L/usr/local/lib 21 21 X11_LIB := -L/usr/X11R6/lib … … 107 107 -lxml2 \ 108 108 -ljpeg -lpng -ltiff \ 109 -lavformat -lavcodec -lavutil \109 -lavformat -lavcodec -lavutil -lswscale \ 110 110 -Wl,-read_only_relocs,suppress 111 111 else trunk/uploadr/MacUploadr.app/Contents/Resources/components/flGM.cpp
r379 r381 23 23 // Goofy FFmpeg requires C linkage 24 24 extern "C" { 25 #include <avcodec.h> 26 #include <avformat.h> 25 #include <libavcodec/avcodec.h> 26 #include <libavformat/avformat.h> 27 #include <libswscale/swscale.h> 27 28 } 28 29 … … 47 48 48 49 #define round(n) (int)(0 <= (n) ? (n) + 0.5 : (n) - 0.5) 50 static int sws_flags = SWS_BICUBIC; 49 51 50 52 using namespace std; … … 451 453 } 452 454 453 // Initialize our GraphicsMagick setup455 // Initialize our GraphicsMagick/ffmpeg setup 454 456 NS_IMETHODIMP flGM::Init(const nsAString & pwd) { 455 457 … … 469 471 delete pwd_s; 470 472 #endif 473 474 // Register all video codecs 475 av_register_all(); 471 476 472 477 return NS_OK; … … 826 831 827 832 // Open the video file and decode it 828 av_register_all();829 833 AVFormatContext *format_ctx; 830 834 if (av_open_input_file(&format_ctx, path_s->c_str(), 0, 0, 0)) { … … 832 836 } 833 837 if (0 > av_find_stream_info(format_ctx)) { return NS_ERROR_NULL_POINTER; } 838 //dump_format(format_ctx, 0, path_s->c_str(), false); 839 834 840 int stream = -1; 835 841 for (int i = 0; i < format_ctx->nb_streams; ++i) { … … 841 847 if (-1 == stream) { return NS_ERROR_NULL_POINTER; } 842 848 AVCodecContext * codec_ctx = format_ctx->streams[stream]->codec; 849 850 // Load the actual codec we found and open the video stream 843 851 AVCodec * codec = avcodec_find_decoder(codec_ctx->codec_id); 844 852 if (!codec) { return NS_ERROR_NULL_POINTER; } … … 846 854 AVFrame * video_frame = avcodec_alloc_frame(); 847 855 AVFrame * img_frame = avcodec_alloc_frame(); 848 if (!video_frame || !img_frame) { eturn NS_ERROR_NULL_POINTER; }856 if (!video_frame || !img_frame) { return NS_ERROR_NULL_POINTER; } 849 857 int bytes = avpicture_get_size(PIX_FMT_RGB24, codec_ctx->width, 850 858 codec_ctx->height); … … 869 877 AVPacket packet; 870 878 int have_frame; 879 struct SwsContext *toRGB_convert_ctx; 871 880 while (0 <= av_read_frame(format_ctx, &packet)) { 872 881 if (packet.stream_index == stream) { 873 882 avcodec_decode_video(codec_ctx, video_frame, &have_frame, 874 883 packet.data, packet.size); 884 875 885 if (have_frame && seek == ++i) { 876 img_convert((AVPicture *)img_frame, PIX_FMT_RGB24, 877 (AVPicture*)video_frame, codec_ctx->pix_fmt, 878 codec_ctx->width, codec_ctx->height); 879 886 //img_convert((AVPicture *)img_frame, PIX_FMT_RGB24, 887 // (AVPicture*)video_frame, codec_ctx->pix_fmt, 888 // codec_ctx->width, codec_ctx->height); 889 890 toRGB_convert_ctx = sws_getContext( 891 codec_ctx->width, codec_ctx->height, codec_ctx->pix_fmt, 892 codec_ctx->width, codec_ctx->height, PIX_FMT_RGB24, 893 sws_flags, NULL, NULL, NULL); 894 if (toRGB_convert_ctx == NULL) { 895 av_log(NULL, AV_LOG_ERROR, 896 "Cannot initialize the toRGB conversion context\n"); 897 exit(1); 898 } 899 900 // img_convert parameters are 2 first destination, then 4 source 901 // sws_scale parameters are context, 4 first source, then 2 destination 902 sws_scale(toRGB_convert_ctx, 903 video_frame->data, video_frame->linesize, 0, codec_ctx->height, 904 img_frame->data, img_frame->linesize); 905 880 906 // Convert the keyframe to a PPM in a byte array 881 907 char header[32]; … … 895 921 bytes_p += b; 896 922 } 897 923 898 924 // Convert the PPM array to a JPEG on disk 899 925 string * thumb_s = 0; … … 946 972 while (*o) { _retval.Append(*o++); } 947 973 } 948 974 949 975 free(bytes); 950 976 av_free_packet(&packet); … … 961 987 avcodec_close(codec_ctx); 962 988 av_close_input_file(format_ctx); 989 sws_freeContext(toRGB_convert_ctx); 963 990 964 991 return NS_OK; trunk/uploadr/README.osx
r378 r381 137 137 ------------------------------------------------------------------------ 138 138 139 Check out the m agicversion of FFmpeg:140 $ svn co -r 10885svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg139 Check out the most recent version of FFmpeg: 140 $ svn co svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg 141 141 $ cd ffmpeg 142 $ cp common.mak subdir.mak143 142 144 143 Then build: 145 144 $ ./configure --disable-ffserver --disable-ffplay --enable-gpl \ 146 --disable-vhook --disable-mmx --enable-static --disable-shared \147 --extra-cflags=-fno-common --disable-debug 145 --disable-vhook --disable-mmx --enable-static --disable-shared \ 146 --extra-cflags=-fno-common --disable-debug --enable-swscale 148 147 $ make && sudo make install 149 148 trunk/uploadr/README.windows
r370 r381 286 286 --- http://wiki.videolan.org/Win32CompileMSYS 287 287 288 Check out and build the m agicversion of FFmpeg:288 Check out and build the most recent version of FFmpeg: 289 289 (handy hint: Shift+Insert pastes into the MSYS shell) 290 290 291 $ svn co -r 10885svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg291 $ svn co svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg 292 292 $ cd ffmpeg 293 293 $ ./configure --disable-ffserver --disable-ffplay --enable-gpl \ 294 294 --enable-memalign-hack --enable-static --disable-shared \ 295 --disable-debug 295 --disable-debug --enable-swscale 296 296 $ make && make install 297 297