Recherche avancée

Médias (0)

Mot : - Tags -/alertes

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (99)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • L’agrémenter visuellement

    10 avril 2011

    MediaSPIP est basé sur un système de thèmes et de squelettes. Les squelettes définissent le placement des informations dans la page, définissant un usage spécifique de la plateforme, et les thèmes l’habillage graphique général.
    Chacun peut proposer un nouveau thème graphique ou un squelette et le mettre à disposition de la communauté.

Sur d’autres sites (12957)

  • Build latest version of FFMPEG with libx264 Android

    12 novembre 2016, par Biraj Zalavadia

    I was able to Build FFMPEG with libx264 Android successfully and was working well before 2 months.

    I uses halfninja for building.

    Today I take latest source of ffmpeg and libX264 from here.

    git clone git://git.videolan.org/x264.git

    git clone git://git.videolan.org/ffmpeg.git

    And try to rebuild whole project. But now it throws following errors.

    ffmpeg.c:2406: error: undefined reference to 'hwaccels'
    ffmpeg.c:3390: error: undefined reference to 'qp_hist'
    ffmpeg.c:3390: error: undefined reference to 'do_hex_dump'
    ffmpeg.c:3390: error: undefined reference to 'do_pkt_dump'
    ffmpeg.c:576: error: undefined reference to 'do_benchmark_all'
    ffmpeg.c:657: error: undefined reference to 'audio_sync_method'
    ffmpeg.c:1222: error: undefined reference to 'vstats_filename'
    ffmpeg.c:972: error: undefined reference to 'frame_drop_threshold'
    ffmpeg.c:1181: error: undefined reference to 'debug_ts'
    ffmpeg.c:2742: error: undefined reference to 'copy_tb'
    ffmpeg.c:2846: error: undefined reference to 'audio_volume'
    ffmpeg.c:2862: error: undefined reference to 'init_simple_filtergraph'
    ffmpeg.c:2863: error: undefined reference to 'configure_filtergraph'
    ffmpeg.c:2923: error: undefined reference to 'video_sync_method'
    ffmpeg.c:2538: error: undefined reference to 'frame_bits_per_raw_sample'
    ffmpeg.c:3258: error: undefined reference to 'sdp_filename'
    ffmpeg.c:2087: error: undefined reference to 'ist_in_filtergraph'
    ffmpeg.c:4069: error: undefined reference to 'ffmpeg_parse_options'
    ffmpeg.c:4074: error: undefined reference to 'show_usage'
    ffmpeg.c:3303: error: undefined reference to 'options'
    ffmpeg.c:3303: error: undefined reference to 'stdin_interaction'
    ffmpeg.c:2553: error: undefined reference to 'exit_on_error'
    ffmpeg.c:2553: error: undefined reference to 'do_pkt_dump'
    ffmpeg.c:2553: error: undefined reference to 'do_hex_dump'
    ffmpeg.c:3727: error: undefined reference to 'copy_ts'
    ffmpeg.c:3727: error: undefined reference to 'dts_delta_threshold'
    ffmpeg.c:268: error: undefined reference to 'dts_error_threshold'
    ffmpeg.c:3976: error: undefined reference to 'print_stats'
    ffmpeg.c:1694: error: undefined reference to 'do_benchmark'
    ffmpeg.c:1694: error: undefined reference to 'max_error_rate'

    Please help me out to resolve this.

    Please look at my script.

    build_android.sh

    #!/bin/bash
    #
    # build_android.sh
    # Copyright (c) 2012 Jacek Marchwicki
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.

    export NDK=/home/tasol/DEVELOPMENT/IJOOMER_DEVELOPMENT/NDK/android-ndk-r10d

    if [ "$NDK" = "" ]; then
       echo NDK variable not set, exiting
       echo "Use: export NDK=/your/path/to/android-ndk"
       exit 1
    fi

    OS=`uname -s | tr '[A-Z]' '[a-z]'`
    function build_x264
    {
       PLATFORM=$NDK/platforms/$PLATFORM_VERSION/arch-$ARCH/
       export PATH=${PATH}:$PREBUILT/bin/
       CROSS_COMPILE=$PREBUILT/bin/$EABIARCH-
       CFLAGS=$OPTIMIZE_CFLAGS
    #CFLAGS=" -I$ARM_INC -fpic -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID  -Wa,--noexecstack -MMD -MP "
       export CPPFLAGS="$CFLAGS"
       export CFLAGS="$CFLAGS"
       export CXXFLAGS="$CFLAGS"
       export CXX="${CROSS_COMPILE}g++ --sysroot=$PLATFORM"
       export AS="${CROSS_COMPILE}gcc --sysroot=$PLATFORM"
       export CC="${CROSS_COMPILE}gcc --sysroot=$PLATFORM"
       export NM="${CROSS_COMPILE}nm"
       export STRIP="${CROSS_COMPILE}strip"
       export RANLIB="${CROSS_COMPILE}ranlib"
       export AR="${CROSS_COMPILE}ar"
       #export LDFLAGS="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog"

       cd x264
       ./configure --disable-asm --prefix=$(pwd)/$PREFIX --host=$ARCH-linux --enable-static $ADDITIONAL_CONFIGURE_FLAG || exit 1

       make clean || exit 1
       make -j4 install || exit 1
       cd ..
    }

    function build_ffmpeg
    {
       PLATFORM=$NDK/platforms/$PLATFORM_VERSION/arch-$ARCH/
       CC=$PREBUILT/bin/$EABIARCH-gcc
       CROSS_PREFIX=$PREBUILT/bin/$EABIARCH-
       PKG_CONFIG=${CROSS_PREFIX}pkg-config
       if [ ! -f $PKG_CONFIG ];
       then
           cat > $PKG_CONFIG << EOF
    #!/bin/bash
    pkg-config \$*
    EOF
           chmod u+x $PKG_CONFIG
       fi
       NM=$PREBUILT/bin/$EABIARCH-nm
       cd ffmpeg
       export PKG_CONFIG_LIBDIR=$(pwd)/$PREFIX/lib/pkgconfig/
       export PKG_CONFIG_PATH=$(pwd)/$PREFIX/lib/pkgconfig/
       ./configure --target-os=linux \
           --prefix=$PREFIX \
           --enable-cross-compile \
           --extra-libs="-lgcc" \
           --arch=$ARCH \
           --cc=$CC \
           --cross-prefix=$CROSS_PREFIX \
           --nm=$NM \
           --sysroot=$PLATFORM \
           --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums  -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
           --disable-shared \
           --disable-stripping \
           --enable-static \
           --enable-runtime-cpudetect \
           --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -nostdlib -lc -lm -ldl -llog -L$PREFIX/lib" \
           --extra-cflags="-I$PREFIX/include" \
               --enable-gpl \
           --enable-encoder=libx264 \
           --enable-libx264 \
           --enable-parser=mjpeg \
           --enable-demuxer=image2 \
           --enable-hwaccel=h264_vaapi \
           --enable-hwaccel=h264_vaapi \
           --enable-hwaccel=h264_dxva2 \
           --enable-hwaccel=mpeg4_vaapi \
           --enable-demuxer=mov \
           --enable-demuxer=h264 \
           --enable-demuxer=mpegvideo \
           --enable-demuxer=h263 \
           --enable-demuxer=mpegps \
           --enable-demuxer=mjpeg \
           --enable-demuxer=rtsp \
           --enable-demuxer=rtp \
           --enable-demuxer=hls \
           --enable-demuxer=matroska \
           --enable-muxer=rtsp \
           --enable-muxer=mp4 \
           --enable-muxer=mov \
           --enable-muxer=mjpeg \
           --enable-muxer=matroska \
           --enable-protocol=crypto \
           --enable-protocol=jni \
           --enable-protocol=file \
           --disable-network \
               --enable-filter=buffer \
           --enable-filter=buffersink \
           --enable-filter=scale \
           --enable-protocol=rtp \
           --enable-protocol=tcp \
           --enable-protocol=udp \
           --enable-protocol=applehttp \
           --enable-protocol=hls \
           --enable-protocol=http \
           --enable-decoder=xsub \
           --enable-decoder=jacosub \
           --enable-decoder=dvdsub \
           --enable-decoder=dvbsub \
           --enable-decoder=subviewer \
           --enable-decoder=rawvideo \
           --enable-encoder=rawvideo \
           --enable-decoder=mjpeg \
           --enable-encoder=mjpeg \
           --enable-decoder=h263 \
           --enable-decoder=mpeg4 \
           --enable-encoder=mpeg4 \
           --enable-decoder=h264 \
           --enable-encoder=h264 \
           --enable-decoder=aac \
           --enable-encoder=aac \
           --enable-parser=h264 \
           --enable-encoder=mp2 \
           --enable-decoder=mp2 \
           --enable-encoder=libvo_amrwbenc \
           --enable-decoder=amrwb \
           --enable-muxer=mp2 \
           --enable-bsfs \
           --enable-decoders \
           --enable-encoders \
           --enable-parsers \
           --enable-hwaccels \
           --enable-muxers \
           --enable-avformat \
           --enable-avcodec \
           --disable-demuxer=v4l \
           --disable-demuxer=v4l2 \
           --disable-indev=v4l \
           --disable-indev=v4l2 \
           --disable-ffplay \
           --disable-ffmpeg \
           --disable-ffplay \
           --disable-ffprobe \
           --disable-ffserver \
           --enable-nonfree \
           --enable-version3 \
           --enable-memalign-hack \
           --disable-asm \
           $ADDITIONAL_CONFIGURE_FLAG \
           || exit 1
       make clean || exit 1
       make -j4 install || exit 1

       cd ..
    }

    function build_one {
       cd ffmpeg
       cd ..
    }

    #arm v5
    EABIARCH=arm-linux-androideabi
    ARCH=arm
    CPU=armv5
    OPTIMIZE_CFLAGS="-marm -march=$CPU"
    PREFIX=../ffmpeg-build/armeabi
    OUT_LIBRARY=$PREFIX/libffmpeg.so
    ADDITIONAL_CONFIGURE_FLAG=
    SONAME=libffmpeg.so
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/$OS-x86_64
    #PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/$OS-x86
    PLATFORM_VERSION=android-5
    build_x264
    build_ffmpeg
    build_one


    #arm v7vfpv3
    #EABIARCH=arm-linux-androideabi
    #ARCH=arm
    #CPU=armv7-a
    #OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
    #PREFIX=../ffmpeg-build/armeabi-v7a
    #OUT_LIBRARY=$PREFIX/libffmpeg.so
    #ADDITIONAL_CONFIGURE_FLAG=
    #SONAME=libffmpeg.so
    #PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/$OS-x86_64
    #PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/$OS-x86
    #PLATFORM_VERSION=android-5
    #build_x264
    #build_ffmpeg
    #build_one

    #arm v7 + neon (neon also include vfpv3-32)
    EABIARCH=arm-linux-androideabi
    ARCH=arm
    CPU=armv7-a
    OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8 -mthumb -D__thumb__ "
    PREFIX=../ffmpeg-build/armeabi-v7a
    #PREFIX=../ffmpeg-build/armeabi-v7a-neon
    OUT_LIBRARY=../ffmpeg-build/armeabi-v7a/libffmpeg-neon.so
    ADDITIONAL_CONFIGURE_FLAG=--enable-neon
    SONAME=libffmpeg-neon.so
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/$OS-x86_64
    #PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/$OS-x86
    PLATFORM_VERSION=android-9
    build_x264
    build_ffmpeg
    build_one

    #x86
    EABIARCH=i686-linux-android
    ARCH=x86
    OPTIMIZE_CFLAGS="-m32"
    PREFIX=../ffmpeg-build/x86
    OUT_LIBRARY=$PREFIX/libffmpeg.so
    ADDITIONAL_CONFIGURE_FLAG=--disable-asm
    SONAME=libffmpeg.so
    PREBUILT=$NDK/toolchains/x86-4.8/prebuilt/$OS-x86_64
    #PREBUILT=$NDK/toolchains/x86-4.6/prebuilt/$OS-x86
    PLATFORM_VERSION=android-9
    build_x264
    build_ffmpeg
    build_one

    #mips
    EABIARCH=mipsel-linux-android
    ARCH=mips
    OPTIMIZE_CFLAGS="-EL -march=mips32 -mips32 -mhard-float"
    PREFIX=../ffmpeg-build/mips
    OUT_LIBRARY=$PREFIX/libffmpeg.so
    ADDITIONAL_CONFIGURE_FLAG=""
    SONAME=libffmpeg.so
    PREBUILT=$NDK/toolchains/mipsel-linux-android-4.8/prebuilt/$OS-x86_64
    #PREBUILT=$NDK/toolchains/mipsel-linux-android-4.6/prebuilt/$OS-x86
    PLATFORM_VERSION=android-9
    build_x264
    build_ffmpeg
    build_one

    build_all.sh

    #!/bin/bash
    #
    # build_all.sh

    export NDK=/home/tasol/DEVELOPMENT/IJOOMER_DEVELOPMENT/NDK/android-ndk-r10d
    sudo ./build_android.sh
    $NDK/ndk-build

    echo "Done Dona Done!!!"

    Android.mk

    LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)
    LOCAL_MODULE  := videokit
    # These need to be in the right order
    FFMPEG_LIBS := $(addprefix ffmpeg-build/$(TARGET_ARCH_ABI)/lib/, \
    libavdevice.a \
    libavformat.a \
    libavfilter.a \
    libavcodec.a \
    libswscale.a \
    libavutil.a \
    libswresample.a \
    libpostproc.a )
    # ffmpeg uses its own deprecated functions liberally, so turn off that annoying noise
    LOCAL_CFLAGS += -g -Iffmpeg -Ivideokit -Wno-deprecated-declarations
    LOCAL_LDLIBS += -llog -lz $(FFMPEG_LIBS) ffmpeg-build/$(TARGET_ARCH_ABI)/lib/libx264.a
    LOCAL_SRC_FILES := videokit/uk_co_halfninja_videokit_Videokit.c videokit/ffmpeg.c videokit/cmdutils.c
    include $(BUILD_SHARED_LIBRARY)


    include $(CLEAR_VARS)
    LOCAL_MODULE  := ffmpeg
    FFMPEG_LIBS := $(addprefix ffmpeg-build/$(TARGET_ARCH_ABI)/lib/, \
    libavdevice.a \
    libavformat.a \
    libavfilter.a \
    libavcodec.a \
    libswscale.a \
    libavutil.a \
    libswresample.a \
    libpostproc.a )
    LOCAL_CFLAGS += -g -Iffmpeg -Ivideokit -Wno-deprecated-declarations
    LOCAL_LDLIBS += -llog -lz $(FFMPEG_LIBS) ffmpeg-build/$(TARGET_ARCH_ABI)/lib/libx264.a
    LOCAL_SRC_FILES := ffmpeg/ffmpeg.c ffmpeg/cmdutils.c
    include $(BUILD_EXECUTABLE)

    Application.mk

    APP_ABI := armeabi,armeabi-v7a,x86,mips
    APP_PLATFORM := android-10
    APP_STL := gnustl_static

    UPDATE

    Finally Got success

  • Live555 : X264 Stream Live source based on "testOnDemandRTSPServer"

    26 octobre 2017, par user2660369

    I am trying to create a rtsp Server that streams the OpenGL output of my program. I had a look at How to write a Live555 FramedSource to allow me to stream H.264 live, but I need the stream to be unicast. So I had a look at testOnDemandRTSPServer. Using the same Code fails. To my understanding I need to provide memory in which I store my h264 frames so the OnDemandServer can read them on Demand.

    H264VideoStreamServerMediaSubsession.cpp

    H264VideoStreamServerMediaSubsession*
    H264VideoStreamServerMediaSubsession::createNew(UsageEnvironment& env,
                             Boolean reuseFirstSource) {
     return new H264VideoStreamServerMediaSubsession(env, reuseFirstSource);
    }

    H264VideoStreamServerMediaSubsession::H264VideoStreamServerMediaSubsession(UsageEnvironment& env, Boolean reuseFirstSource)
     : OnDemandServerMediaSubsession(env, reuseFirstSource), fAuxSDPLine(NULL), fDoneFlag(0), fDummyRTPSink(NULL) {
    }

    H264VideoStreamServerMediaSubsession::~H264VideoStreamServerMediaSubsession() {
     delete[] fAuxSDPLine;
    }

    static void afterPlayingDummy(void* clientData) {
     H264VideoStreamServerMediaSubsession* subsess = (H264VideoStreamServerMediaSubsession*)clientData;
     subsess->afterPlayingDummy1();
    }

    void H264VideoStreamServerMediaSubsession::afterPlayingDummy1() {
     // Unschedule any pending 'checking' task:
     envir().taskScheduler().unscheduleDelayedTask(nextTask());
     // Signal the event loop that we're done:
     setDoneFlag();
    }

    static void checkForAuxSDPLine(void* clientData) {
     H264VideoStreamServerMediaSubsession* subsess = (H264VideoStreamServerMediaSubsession*)clientData;
     subsess->checkForAuxSDPLine1();
    }

    void H264VideoStreamServerMediaSubsession::checkForAuxSDPLine1() {
     char const* dasl;

     if (fAuxSDPLine != NULL) {
       // Signal the event loop that we're done:
       setDoneFlag();
     } else if (fDummyRTPSink != NULL && (dasl = fDummyRTPSink->auxSDPLine()) != NULL) {
       fAuxSDPLine = strDup(dasl);
       fDummyRTPSink = NULL;

       // Signal the event loop that we're done:
       setDoneFlag();
     } else {
       // try again after a brief delay:
       int uSecsToDelay = 100000; // 100 ms
       nextTask() = envir().taskScheduler().scheduleDelayedTask(uSecsToDelay,
                     (TaskFunc*)checkForAuxSDPLine, this);
     }
    }

    char const* H264VideoStreamServerMediaSubsession::getAuxSDPLine(RTPSink* rtpSink, FramedSource* inputSource) {
     if (fAuxSDPLine != NULL) return fAuxSDPLine; // it's already been set up (for a previous client)

     if (fDummyRTPSink == NULL) { // we're not already setting it up for another, concurrent stream
       // Note: For H264 video files, the 'config' information ("profile-level-id" and "sprop-parameter-sets") isn't known
       // until we start reading the file.  This means that "rtpSink"s "auxSDPLine()" will be NULL initially,
       // and we need to start reading data from our file until this changes.
       fDummyRTPSink = rtpSink;

       // Start reading the file:
       fDummyRTPSink->startPlaying(*inputSource, afterPlayingDummy, this);

       // Check whether the sink's 'auxSDPLine()' is ready:
       checkForAuxSDPLine(this);
     }

     envir().taskScheduler().doEventLoop(&fDoneFlag);

     return fAuxSDPLine;
    }

    FramedSource* H264VideoStreamServerMediaSubsession::createNewStreamSource(unsigned /*clientSessionId*/, unsigned& estBitrate) {
     estBitrate = 500; // kb
     megamol::remotecontrol::View3D_MRC *parent = (megamol::remotecontrol::View3D_MRC*)this->parent;
     return H264VideoStreamFramer::createNew(envir(), parent->h264FramedSource);
    }

    RTPSink* H264VideoStreamServerMediaSubsession::createNewRTPSink(Groupsock* rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource* /*inputSource*/) {
     return H264VideoRTPSink::createNew(envir(), rtpGroupsock, rtpPayloadTypeIfDynamic);
    }

    FramedSource.cpp

    H264FramedSource* H264FramedSource::createNew(UsageEnvironment& env,
                                             unsigned preferredFrameSize,
                                             unsigned playTimePerFrame)
    {
       return new H264FramedSource(env, preferredFrameSize, playTimePerFrame);
    }

    H264FramedSource::H264FramedSource(UsageEnvironment& env,
                                  unsigned preferredFrameSize,
                                  unsigned playTimePerFrame)
       : FramedSource(env),
       fPreferredFrameSize(fMaxSize),
       fPlayTimePerFrame(playTimePerFrame),
       fLastPlayTime(0),
       fCurIndex(0)
    {

       x264_param_default_preset(&param, "veryfast", "zerolatency");
       param.i_threads = 1;
       param.i_width = 1024;
       param.i_height = 768;
       param.i_fps_num = 30;
       param.i_fps_den = 1;
       // Intra refres:
       param.i_keyint_max = 60;
       param.b_intra_refresh = 1;
       //Rate control:
       param.rc.i_rc_method = X264_RC_CRF;
       param.rc.f_rf_constant = 25;
       param.rc.f_rf_constant_max = 35;
       param.i_sps_id = 7;
       //For streaming:
       param.b_repeat_headers = 1;
       param.b_annexb = 1;
       x264_param_apply_profile(&param, "baseline");

       param.i_log_level = X264_LOG_ERROR;

       encoder = x264_encoder_open(&param);
       pic_in.i_type            = X264_TYPE_AUTO;
       pic_in.i_qpplus1         = 0;
       pic_in.img.i_csp         = X264_CSP_I420;
       pic_in.img.i_plane       = 3;


       x264_picture_alloc(&pic_in, X264_CSP_I420, 1024, 768);

       convertCtx = sws_getContext(1024, 768, PIX_FMT_RGBA, 1024, 768, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
       eventTriggerId = envir().taskScheduler().createEventTrigger(deliverFrame0);
    }

    H264FramedSource::~H264FramedSource()
    {
       envir().taskScheduler().deleteEventTrigger(eventTriggerId);
       eventTriggerId = 0;
    }

    void H264FramedSource::AddToBuffer(uint8_t* buf, int surfaceSizeInBytes)
    {
       uint8_t* surfaceData = (new uint8_t[surfaceSizeInBytes]);

       memcpy(surfaceData, buf, surfaceSizeInBytes);

       int srcstride = 1024*4;
       sws_scale(convertCtx, &surfaceData, &srcstride,0, 768, pic_in.img.plane, pic_in.img.i_stride);
       x264_nal_t* nals = NULL;
       int i_nals = 0;
       int frame_size = -1;


       frame_size = x264_encoder_encode(encoder, &nals, &i_nals, &pic_in, &pic_out);

       static bool finished = false;

       if (frame_size >= 0)
       {
       static bool alreadydone = false;
       if(!alreadydone)
       {

           x264_encoder_headers(encoder, &nals, &i_nals);
           alreadydone = true;
       }
       for(int i = 0; i < i_nals; ++i)
       {
           m_queue.push(nals[i]);
       }
       }
       delete [] surfaceData;
       surfaceData = nullptr;

       envir().taskScheduler().triggerEvent(eventTriggerId, this);
    }

    void H264FramedSource::doGetNextFrame()
    {
       deliverFrame();
    }

    void H264FramedSource::deliverFrame0(void* clientData)
    {
       ((H264FramedSource*)clientData)->deliverFrame();
    }

    void H264FramedSource::deliverFrame()
    {
       x264_nal_t nalToDeliver;

       if (fPlayTimePerFrame > 0 && fPreferredFrameSize > 0) {
       if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0) {
           // This is the first frame, so use the current time:
           gettimeofday(&fPresentationTime, NULL);
       } else {
           // Increment by the play time of the previous data:
           unsigned uSeconds   = fPresentationTime.tv_usec + fLastPlayTime;
           fPresentationTime.tv_sec += uSeconds/1000000;
           fPresentationTime.tv_usec = uSeconds%1000000;
       }

       // Remember the play time of this data:
       fLastPlayTime = (fPlayTimePerFrame*fFrameSize)/fPreferredFrameSize;
       fDurationInMicroseconds = fLastPlayTime;
       } else {
       // We don't know a specific play time duration for this data,
       // so just record the current time as being the 'presentation time':
       gettimeofday(&fPresentationTime, NULL);
       }

       if(!m_queue.empty())
       {
       m_queue.wait_and_pop(nalToDeliver);

       uint8_t* newFrameDataStart = (uint8_t*)0xD15EA5E;

       newFrameDataStart = (uint8_t*)(nalToDeliver.p_payload);
       unsigned newFrameSize = nalToDeliver.i_payload;

       // Deliver the data here:
       if (newFrameSize > fMaxSize) {
           fFrameSize = fMaxSize;
           fNumTruncatedBytes = newFrameSize - fMaxSize;
       }
       else {
           fFrameSize = newFrameSize;
       }

       memcpy(fTo, nalToDeliver.p_payload, nalToDeliver.i_payload);

       FramedSource::afterGetting(this);
       }
    }

    Relevant part of the RTSP-Server Therad

     RTSPServer* rtspServer = RTSPServer::createNew(*(parent->env), 8554, NULL);
     if (rtspServer == NULL) {
       *(parent->env) << "Failed to create RTSP server: " << (parent->env)->getResultMsg() << "\n";
       exit(1);
     }
     char const* streamName = "Stream";
     parent->h264FramedSource = H264FramedSource::createNew(*(parent->env), 0, 0);
     H264VideoStreamServerMediaSubsession *h264VideoStreamServerMediaSubsession = H264VideoStreamServerMediaSubsession::createNew(*(parent->env), true);
     h264VideoStreamServerMediaSubsession->parent = parent;
     sms->addSubsession(h264VideoStreamServerMediaSubsession);
     rtspServer->addServerMediaSession(sms);

     parent->env->taskScheduler().doEventLoop(); // does not return

    Once a connection exists the render loop calls

    h264FramedSource->AddToBuffer(videoData, 1024*768*4);
  • How to directly download ffmpeg output without saving it in the server in PHP Codeigniter

    19 mai 2017, par Jeeva

    I’ve a video which is converted and then i want to output it as a download file. is there any way to do so. below is a small example.

    $video = "C:\Users\user.folder\Downloads\Hamein_Tumse_Pyar_Kitna_no_audio.mp4";
    $audio = "C:\Users\user.folder\Downloads\Hamein_Tumse_Pyar_Kitna_audio.mp3";
    $cmd = FCPATH.'ffmpeg/bin';

    $this->load->helper('download');
    $data = file_get_contents(shell_exec($cmd.'\ffmpeg -i '.$video.' -i '.$audio.' -c:v copy -c:a copy '.$cmd.'\output.mp4 -y 2>&1'));
    force_download('download_file.mp4',$data);exit;