Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • Looping of bash script

    10 février 2020, par Daniel Peters

    Once I start this convertscript.sh I want it to constantly check the files in the directory, if theres an .mkv it will convert it which it does fine at the moment, but when there are no mkv files left it seems to exit out the script, but I want it to loop and keep trying the script constantly.

    Basically if a new file gets added say during the night because the script is looping constantly it picks it up, I don't want to run the convertscript.sh again. I want to run convertscript.sh once initially and then not touch it.

    The script I've got so far is below:

    shopt -s globstar
    for f in **/*.mkv
    do 
        ffmpeg -i "$f" -c:v libx264 -preset ultrafast -minrate 4.5M -maxrate 4.5M -bufsize 9M -c:a ac3 "${f%mkv}mp4";
        [[ $? -eq 0 ]] && rm "$f";
    done
    
  • prevent ffmpeg from opening console window

    10 février 2020, par Yesub

    I have a node/express server which is used to give streams from IP camera to a website. Everything is working well. I run that webserver with PM2 on a windows server.

    The problem : for each stream I have a windows console opening with just nothing logged in. The console reopen when I try to close it.

    Is there a way to prevent those console to open ?

    Here is the related node.js code :

    const { NodeMediaServer } = require('node-media-server');
    
    private _initiate_streams(): void{
        DatabaseProvider.instance.camerasDao.getCamerasList().pipe(
          take(1)
        ).subscribe(
            (databaseReadOperationResult: DatabaseReadOperationResult) => {
                if (databaseReadOperationResult.successful === true){
                  const cameras = databaseReadOperationResult.result;
                  const tasks = [];
                  cameras.forEach( camera => {
                    tasks.push(
                      {
                        app : config.get('media_server.app_name'),
                        mode: 'static',
                        edge: camera.rtsp_url,
                        name: camera.stream_name,
                        rtsp_transport: 'tcp'
                      }
                    )
                  });
    
                  const configMediaServer = {
                    logType: 3, // 3 - Log everything (debug)
                    rtmp: {
                        port: 1935,
                        chunk_size: 60000,
                        gop_cache: true,
                        ping: 60,
                        ping_timeout: 30
                    },
                    http: {
                        port: config.get('media_server.port'),
                        allow_origin: '*'
                    },
                    auth: {
                        play: true,
                        api: true,
                        publish: true,
                        secret: config.get('salt'),
                        api_user: 'user',
                        api_pass: 'password',
                    },
                    relay: {
                        ffmpeg: 'C:\\FFmpeg\\bin\\ffmpeg.exe',
                        tasks: tasks
                    }
                  };
    
                  var nms = new NodeMediaServer(configMediaServer)
                  nms.run();
                } else {
                    // catch exception
                }
            }
        );
      }
    
  • Using ffmpeg WITHOUT x264 or mpeg4

    10 février 2020, par FunkyPizza

    So I've recently started implementing ffmpeg in an application that I do intend to distribute commercially. And I've had an hard time getting my head around the whole licensing process.

    The most commonly answered question I've seen seems to be about x264 which requires a paid licence from x264.org in order to use it commercially (right?). I started to look into mpeg4 instead but that too seemed to be locked behind some licensing fee (https://www.mpegla.com/programs/mpeg-4-visual/license-agreement/).

    I guess my question is the following, what video encoders compatible with FFMPEG are fully free to use?

  • Batch convert .mp4 into hls segented streams

    10 février 2020, par Dude2019

    I have a system setup to record videos from multipul ip cameras into mp4 files at the end of everyday a new folder is created and the next days worth of cam footage is saved in here and so on day after day.

    I am trying to convert each of these mp4 files into segmented hls streams i can convert a single file with no problems using the following code

    ffmpeg -i cam10029.mp4 -threads 0 -vf scale=1280:-2:force_original_aspect_ratio=decrease -c:a aac -ar 48000 -b:a 128k -c:v h264 -profile:v main -crf 20 -g 48 -keyint_min 48 -sc_threshold 0 -b:v 1500k -maxrate 2675k -bufsize 3750k -hls_time 6 -hls_playlist_type vod -hls_segment_filename index_%03d.ts index.m3u8
    

    but each folder can have sometimes 100-200 videos in it and doing this one by one takes for ever changing the name and rerunning the command and having to check when done

    i tried using something like this

    for i in *.mp4;
      do name=`echo "$i" | cut -d'.' -f1`
      echo "$name"
      ffmpeg -i "$i" "${name}.mov"
    done
    

    sadly this did not work on windows in a batch file it just flickered on screen then gone.

    I am now using ubuntu 18 and wondering if there is a way todo it better on here ?

    what i would like to do is run say one convert.sh file and have it find all the videos in the folder then create a new folder for the first video with the same name as the video then convert it into segmented stream and save the .ts and .m3u8 files in this folder delete the origenal video file then move onto the next file and do the same until all the files are converted in the folder so i can then link to the m3u8 files for each camera via my android app

  • ffmpeg to Youtube Live stops working. ffmpeg continues to run

    10 février 2020, par Robert Pringle

    I'm streaming a mobotix camera to Youtube Live.

    This works correctly for a period of time. Youtube then reports the stream as "noData". ffmpeg continues to run, but no video is being received by Youtube.

    The problem is intermittant.

    Restarting the ffmpeg process makes Youtube start receiving the stream again.

    ffmpeg is being run as a systemd service.

    ffmpeg is run with the following command:

    ffmpeg -nostdin -f lavfi -i anullsrc -rtsp_transport tcp -thread_queue_size 512 -i "rtsp://@192.168.1.1:554/mobotix.h264" -tune zerolatency -vcodec libx264 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/

    Logs only show: ffmpeg[47357]: [48.0K blob data]

    Any ideas on how to solve this? Or improve the logging.

    Edit: Logs from starting ffmpeg:

    
        Feb 07 17:57:00 localhost.localdomain ffmpeg[49525]: [48.0K blob data]
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]:       encoder         : Lavc58.54.100 aac
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]:     Metadata:
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]:     Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]:     Stream #0:0: Video: h264 (Constrained Baseline) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1024x768, q=2-31, 12.50 tbr, 1k tbn, 90k tbc
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]:     encoder         : Lavf58.29.100
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]:   Metadata:
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]: Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/':
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]:   Stream #0:0 -> #0:1 (pcm_u8 (native) -> aac (native))
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]:   Stream #1:0 -> #0:0 (copy)
        Feb 07 17:52:47 localhost.localdomain ffmpeg[49525]: Stream mapping:
        Feb 07 17:52:46 localhost.localdomain ffmpeg[49525]:     Stream #1:0: Video: h264 (Constrained Baseline), yuv420p(progressive), 1024x768, 12.50 tbr, 90k tbn, 180k tbc
        Feb 07 17:52:46 localhost.localdomain ffmpeg[49525]:   Duration: N/A, start: 136.139322, bitrate: N/A
        Feb 07 17:52:46 localhost.localdomain ffmpeg[49525]:     comment         : mobotix.h264
        Feb 07 17:52:46 localhost.localdomain ffmpeg[49525]:     title           : Mobotix IP-Camera (H.264, unicast)
        Feb 07 17:52:46 localhost.localdomain ffmpeg[49525]:   Metadata:
        Feb 07 17:52:46 localhost.localdomain ffmpeg[49525]: Input #1, rtsp, from 'rtsp://@192.168.1.1:554/mobotix.h264':
        Feb 07 17:52:44 localhost.localdomain ffmpeg[49525]: [h264 @ 0x559ee7857940] concealing 2400 DC, 2400 AC, 2400 MV errors in P frame
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:     Stream #0:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   Duration: N/A, start: 0.000000, bitrate: 705 kb/s
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]: Input #0, lavfi, from 'anullsrc':
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libpostproc    55.  5.100 / 55.  5.100
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libswresample   3.  5.100 /  3.  5.100
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libswscale      5.  5.100 /  5.  5.100
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libavresample   4.  0.  0 /  4.  0.  0
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libavfilter     7. 57.100 /  7. 57.100
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libavdevice    58.  8.100 / 58.  8.100
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libavformat    58. 29.100 / 58. 29.100
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libavcodec     58. 54.100 / 58. 54.100
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   libavutil      56. 31.100 / 56. 31.100
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 >
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]:   built with gcc 8 (GCC)
        Feb 07 17:52:43 localhost.localdomain ffmpeg[49525]: ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
    
    

    Running the command manually gave me logs and exited, whereas the systemd service keeps running.

    
        [flv @ 0x560541a8b3c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
        av_interleaved_write_frame(): Broken pipekB time=03:35:18.84 bitrate=3131.8kbits/s speed=0.999x    
            Last message repeated 1 times
        [flv @ 0x560541a8b3c0] Failed to update header with correct duration.
        [flv @ 0x560541a8b3c0] Failed to update header with correct filesize.
        Error writing trailer of rtmp://a.rtmp.youtube.com/live2/: Broken pipe
        frame=134427 fps= 10 q=-1.0 Lsize= 4938869kB time=03:35:18.96 bitrate=3131.8kbits/s speed=0.997x    
        video:4923745kB audio:3296kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.240068%
        [aac @ 0x560541a6d680] Qavg: 65536.000
        Conversion failed!