Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • ffmpeg produces "is_avc" = false with h264_nvenc & tee muxer

    14 août 2018, par Areeb111

    I am using ffmpeg for encoding MKV (Matroska Video files) to 2x MP4 (H264 - 720p Main@L4) & (H264 - 360p Baseline@L3.1).

    Having really strange problem when using -c:v h264_nvenc and tee muxer then the produced output file is having is_avc=false even i have checked the same input matroska file with another server running with Intel QuickSync -c:v h264_qsv with the same command then the produced output file is is_avc=true.

    The main goal that i want the is_avc=true is because the files must be played using nginx-vod-module which requires the AVC video format to be streamed.

    Steps to reproduce the problem:

    • Custom ffmpeg build with NVENC support ffmpeg version N-91182-gbdf1bbd Copyright (c) 2000-2018 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-28)
    • ffprobe version 4.0.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2018 the FFmpeg developers
    • Running ffmpeg command line with NVENC and tee muxer
      /root/ffmpeg  -y -t 00:00:50 -i "testinput.mkv" -filter_complex "[0:v]split=2[s0][s1];[s0]scale=-2:720[v0];[s1]scale=-2:360[v1]" -map "[v0]" -map "[v1]" -map 0:a -c:v h264_nvenc -b:v:0 1100k -b:v:1 600k -profile:v:0 main -profile:v:1 baseline -level:v:0 4 -level:v:1 3.1 -ac 2 -c:a aac -b:a 128k -af "aresample=async=1000:first_pts=0"  -f tee "[select=\'v:0,a\']testoutput.mp4|[select=\'v:1,a\']testoutput-360.mp4"
    • Running ffprobe for the output file to check "is_avc":
      ./ffprobe -v quiet -print_format json -show_format -show_streams testoutput.mp4
    • My current ffprobe output results are:

      
      ./ffprobe -v quiet -print_format json -show_format -show_streams testoutput.mp4
       {
          "streams": [
              {
                  "index": 0,
                  "codec_name": "h264",
                  "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
                  "profile": "Main",
                  "codec_type": "video",
                  "codec_time_base": "1001/48000",
                  "codec_tag_string": "avc1",
                  "codec_tag": "0x31637661",
                  "width": 1280,
                  "height": 720,
                  "coded_width": 1280,
                  "coded_height": 720,
                  "has_b_frames": 0,
                  "sample_aspect_ratio": "1:1",
                  "display_aspect_ratio": "16:9",
                  "pix_fmt": "yuv420p",
                  "level": 40,
                  "chroma_location": "left",
                  "refs": 1,
                  "is_avc": "false",
                  "nal_length_size": "0",
                  "r_frame_rate": "24000/1001",
                  "avg_frame_rate": "24000/1001",
                  "time_base": "1/24000",
                  "start_pts": 984,
                  "start_time": "0.041000",
                  "duration_ts": 1201200,
                  "duration": "50.050000",
                  "bit_rate": "845035",
                  "bits_per_raw_sample": "8",
                  "nb_frames": "1199",
                  "disposition": {
                      "default": 1,
                      "dub": 0,
                      "original": 0,
                      "comment": 0,
                      "lyrics": 0,
                      "karaoke": 0,
                      "forced": 0,
                      "hearing_impaired": 0,
                      "visual_impaired": 0,
                      "clean_effects": 0,
                      "attached_pic": 0,
                      "timed_thumbnails": 0
                  },
                  "tags": {
                      "language": "und",
                      "handler_name": "VideoHandler"
                  }
              },
              {
                  "index": 1,
                  "codec_name": "aac",
                  "codec_long_name": "AAC (Advanced Audio Coding)",
                  "profile": "LC",
                  "codec_type": "audio",
                  "codec_time_base": "1/48000",
                  "codec_tag_string": "mp4a",
                  "codec_tag": "0x6134706d",
                  "sample_fmt": "fltp",
                  "sample_rate": "48000",
                  "channels": 2,
                  "channel_layout": "stereo",
                  "bits_per_sample": 0,
                  "r_frame_rate": "0/0",
                  "avg_frame_rate": "0/0",
                  "time_base": "1/48000",
                  "start_pts": 0,
                  "start_time": "0.000000",
                  "duration_ts": 2401488,
                  "duration": "50.031000",
                  "bit_rate": "129153",
                  "max_bit_rate": "129153",
                  "nb_frames": "2346",
                  "disposition": {
                      "default": 1,
                      "dub": 0,
                      "original": 0,
                      "comment": 0,
                      "lyrics": 0,
                      "karaoke": 0,
                      "forced": 0,
                      "hearing_impaired": 0,
                      "visual_impaired": 0,
                      "clean_effects": 0,
                      "attached_pic": 0,
                      "timed_thumbnails": 0
                  },
                  "tags": {
                      "language": "ger",
                      "handler_name": "SoundHandler"
                  }
              }
          ],
          "format": {
              "filename": "Leonmusssterben20171080p.mp4",
              "nb_streams": 2,
              "nb_programs": 0,
              "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
              "format_long_name": "QuickTime / MOV",
              "start_time": "0.000000",
              "duration": "50.031000",
              "size": "6116472",
              "bit_rate": "978029",
              "probe_score": 100,
              "tags": {
                  "major_brand": "isom",
                  "minor_version": "512",
                  "compatible_brands": "isomiso2avc1mp41",
                  "encoder": "Lavf58.17.100"
              }
          }
      }
      

    Please anyone can help me why is the output video file is getting "is_avc=false" ?

    Is there any option to force it ?

    Thank you

  • C# and FFmpeg preferably without shell commands ?

    14 août 2018, par Dominic Bou-Samra

    I'd like to be able to use FFmpeg to convert a video file from within my C# program. I know I can just call a shell command, but is there a better way?

    The issue with invoking a command via the shell, is I'm not sure you could do things like a progress bar, etc... or could you?

    If there isn't a way, can anyone suggest the best way to layout some framework for executing shell commands. Passing one big long string is very cumbersome atm.

  • ffmpeg run from shell runs properly, but does not when called from within .NET

    14 août 2018, par Bevin

    I'm attempting to use ffmpeg (compiled on Windows with Cygwin) in a C# program, by using the Process class to spawn an ffmpeg instance. However, I've hit a rather odd bug that doesn't make much sense.

    When I run ffmpeg directly from a shell (be it Cygwin's bash, PowerShell, cmd), ffmpeg can properly decode and reencode files without any issues:

    PS C:\audio> ffmpeg -i .\sound1.wav -acodec libvorbis -f ogg abc.ogg
    ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
      built on Apr  8 2013 15:10:40 with gcc 4.5.3 (GCC)
      configuration: --disable-encoder=vorbis --enable-libvorbis
      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
    [wav @ 0x800538a0] max_analyze_duration 5000000 reached at 5015510 microseconds
    Guessed Channel Layout for  Input Stream #0.0 : stereo
    Input #0, wav, from '.\sound1.wav':
      Metadata:
        encoder         : Lavf54.63.104
      Duration: 00:00:05.76, bitrate: 1411 kb/s
        Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
    Output #0, ogg, to 'abc.ogg':
      Metadata:
        encoder         : Lavf54.63.104
        Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp
    Stream mapping:
      Stream #0:0 -> #0:0 (pcm_s16le -> libvorbis)
    Press [q] to stop, [?] for help
    size=      55kB time=00:00:05.74 bitrate=  78.5kbits/s
    video:0kB audio:51kB subtitle:0 global headers:4kB muxing overhead 0.817473%
    

    The file plays fine, and I can encode to WAV or any other format I like. However, when I call ffmpeg from C# with the following code:

    string tempfile = Path.GetTempFileName();
    FileStream tempfilestr = File.OpenWrite(tempfile);
    input.CopyTo(tempfilestr);
    
    ProcessStartInfo pstart = new ProcessStartInfo("ffmpeg", string.Format("-i \"{0}\" -v verbose -y -f wav -", tempfile));
    pstart.CreateNoWindow = true;
    pstart.ErrorDialog = false;
    pstart.RedirectStandardOutput = true;
    pstart.RedirectStandardError = true;
    pstart.UseShellExecute = false;
    
    
    Process proc = new Process();
    proc.StartInfo = pstart;
    proc.Start();
    StreamReader stdout = proc.StandardOutput;
    StreamReader stderr = proc.StandardError;
    
    outtempfilestr = File.OpenRead(outtempfile);
    MemoryStream output = new MemoryStream();
    
    stdout.BaseStream.CopyTo(output);
    
    try {
        proc.Kill();
    }
    catch(InvalidOperationException) { }
    catch(Win32Exception) { }
    
    File.Delete(tempfile);
    
    return output.ToArray();
    

    This randomly produces errors in the output:

    ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
      built on Apr  8 2013 15:10:40 with gcc 4.5.3 (GCC)
      configuration: --disable-encoder=vorbis --enable-libvorbis
      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
    [wav @ 0x80053860] parser not found for codec pcm_s16le, packets or times may be invalid.
        Last message repeated 1 times
    [wav @ 0x80053860] max_analyze_duration 5000000 reached at 5015510 microseconds
    Guessed Channel Layout for  Input Stream #0.0 : stereo
    Input #0, wav, from 'C:\Users\Bevin\AppData\Local\Temp\tmp1CCE.tmp':
      Duration: 00:00:05.20, bitrate: 1411 kb/s
        Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
    [graph 0 input from stream 0:0 @ 0x8011f320] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
    Output #0, wav, to 'pipe:':
      Metadata:
        ISFT            : Lavf54.63.104
        Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
    Stream mapping:
      Stream #0:0 -> #0:0 (pcm_s16le -> pcm_s16le)
    Press [q] to stop, [?] for help
    Multiple frames in a packet from stream 0
    [pcm_s16le @ 0x8005c160] Invalid PCM packet, data has size 3 but at least a size of 4 was expected
    Error while decoding stream #0:0: Invalid data found when processing input
    No more output streams to write to, finishing.
    size=     896kB time=00:00:05.20 bitrate=1411.3kbits/s    
    video:0kB audio:896kB subtitle:0 global headers:0kB muxing overhead 0.008719%
    

    Note that these errors don't always occur. Sometimes they happen for certain files, sometimes they don't. I've tried various combinations of stream redirects and temp files, none of them work. I've also verified the integrity of the temp files, and it all checks out. I've even extracted the temp file before it was deleted, and decoded it in shell without a hitch.

    Any ideas?

    Edit: I've tried running ffmpeg from a shell script that's run through C#. It gives the same issues. Compiling ffmpeg via MinGW gives the same issue as well.

  • How to use pipe in ffmpeg within c#

    14 août 2018, par Andrew Simpson

    I have 100 jpegs.

    I use ffmpeg to encode to a video file which is written to a hard drive.

    Is there a way to pipe it directly to a byte/stream?

    I am using C# and I am using the process class to initate ffmpeg.

    Thanks

  • HLS stream from multiple FFMPEG to RTMP command at VideoJS keep repeating for segments

    14 août 2018, par Lokesh Kumawat

    I am building on demand video streaming application based on user interaction at frontend using FFMPEG and RTMP, which eventually converted to HLS using nginx-rtmp-module, with hls_continuous flag set to true.

    While running back to back FFMPEG command to RTMP(i.e. once one FFMPEG command done with execution at RTMP stream, another FFMPEG command is executed at same stream), observation at VideoJs player that some of the HLS segment keeps repeating.

    Would be great help if someone could help me to figure out what could be possible reason, and how to fix the same?

    Thanks in Advance.