Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFMPEG to both save a file and stream to MPLayer on a different computer

    8 octobre 2016, par Laurent Bazinet

    Here's what i'm trying to do: Have a raspberry pi grab a video with a camera, using raspivid and pipe this directly to my main computer, which would act as a kind of server, by both saving the video, and allowing a live stream using MPlayer to be displayed by another computer on the network.

    My problem is only on the last part: display the stream on another computer.

    For clarity, Main computer is going to be Comp-A, and the computer running MPlayer will be Comp-X (because this can be any computer on my network, or even outside my network)

    If we follow the information, here's how i've done it so far: Grab the video and pipe it to the network (this is done on the raspberry pi)

    raspivid -t 0 -w 1280 -h 720 -a 12 -ih -v -fps 30 -n -o - | sudo nc -k -w 1 -l 80
    

    This works great for my purpose.

    Next, on Comp-A, I'm grabbing this stream with FFMPEG, and tee-ing to both a file and a UDP stream using this command:

    ffmpeg -i tcp://raspberryIP:80 -c:v h264 -f tee -map 0:v "[f=stream_segment:segment_wrap=25:segment_time=3600:reset_timestamps=1]output%%03d.mp4|[f=mpegts]udp://maincomputerIP:80"
    

    (side note, the [f=stream_segment:segment_wrap=25:segment_time=3600:reset_timestamps=1] is to have 25 videos of 1 hour long, and looping)

    Then I run into issues.

    If I run this on Comp-A: mplayer -fps 200 -demuxer mpegts "udp://Comp-A-IP:80" It works great.

    If I run the same command on Comp-X, it doesn't work.

    If I change the [f=mpegts]udp://Comp-A-IP:80" to [f=mpegts]udp://Comp-X-IP:80", then the Comp-X works, but the Comp-A doesn't anymore.

    This leads me to believe my issue is that the UDP url from FFMPEG is asking for the computer it's going to connect to, not the host computer.

    My problem is that Comp-X's IP is unknown.

    Is there a way? Maybe I'm over-complicating things. I don't know.

  • how to output gif with same size as input video

    7 octobre 2016, par Maxlight

    I am following How do I convert a video to GIF using ffmpeg, with reasonable quality?

    It gives example:

    ffmpeg -i input.flv -i palette.png -filter_complex "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
    

    However I want the gif output to be the same size as video and not 320 as specified here so I removed scale=320:-1 so I have

    ffmpeg -i input.flv -i palette.png -filter_complex "fps=10,flags=lanczos[x];[x][1:v]paletteuse" output.gif
    

    When I run that I get:

    No such filter: 'flags' Error initializing complex filters.
    

    If I remove:

    -filter_complex "fps=10,flags=lanczos[x];[x][1:v]paletteuse"
    

    Then it works but quality of the video is bad. So it seems that I must use a scale for those palette flags to work, how can I get ffmpeg to output gif same size as input video?

  • Issue when streaming some TV channels threw ffMpeg

    7 octobre 2016, par Raphael Serievic

    I am trying to stream a TV Tuner feed with ffMpeg through udp.

    The ffMpeg command line I use is the following :

    ffmpeg.exe -i udp://@239.255.255.9:1234 -map 0:p:1317:0 -profile:v baseline -crf 30 -preset ultrafast -vcodec libx264 -r 25 -vf scale=720:576-b:v 500k -f rtp udp://10.150.112.107:15048/ -map 0:p:1317:1 -acodec pcm_mulaw -strict experimental -ar 8k -ac 1 -b:a 128k -f rtp udp://10.150.112.107:15032/
    

    Where:

    • 1317 is the program id (channel)
    • 10.150.112.107 is where I want to stream the TV channel
    • 239.255.255.9 is where I receive the original TV channel's feed from my TV Tuner

    My problem is that with some program IDs it is working and with some others it is not : it is working with 1572 ("channel 10 hd") but not with 1317 ("7flix Sydney").

    The output of this command-line for channel 1572 (where it works) is the following :

    C:\Program Files (x86)\Tuner Manager\ServerModule> ffmpeg.exe
     -i udp://@239.255.255.7:1234 -map 0:p:1572:0 -profile:v baseline -crf 30 -prese
    t ultrafast -vcodec libx264 -r 25 -vf scale=720:576 -    b:v 500k -f rtp udp://1
    0.150.112.107:15048/ -map 0:p:1572:1 -acodec pcm_mulaw -strict experimental -ar
    8k -ac 1 -b:a 128k -f rtp udp://10.150.112.107:15032/
    ffmpeg version N-71924-ga2190de Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
    enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
    ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
    le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
    able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
    ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
     --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
    e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
    ble-decklink --enable-zlib
      libavutil      54. 23.101 / 54. 23.101
      libavcodec     56. 37.100 / 56. 37.100
      libavformat    56. 31.102 / 56. 31.102
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5. 16.101 /  5. 16.101
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    [NULL @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 00000000049cc980] Invalid frame dimensions 0x0.
    [mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
        Last message repeated 1 times
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [mpeg2video @ 00000000049cc980] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [mpeg2video @ 00000000049cc980] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 00000000049cc980] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
        Last message repeated 1 times
    [mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
    [mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
        Last message repeated 1 times
    [mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
    [mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
    [h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
    [h264 @ 00000000049ce980] non-existing PPS 0 referenced
    [h264 @ 00000000049ce980] decode_slice_header error
    [h264 @ 00000000049ce980] no frame!
    [mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
        Last message repeated 2 times
    [mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
    [mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
        Last message repeated 3 times
    [mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
    [mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
        Last message repeated 3 times
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 2 (Unknow
    n: none ([11][0][0][0] / 0x000B)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 3 (Unknow
    n: none ([5][0][0][0] / 0x0005)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 4 (Unknow
    n: none ([11][0][0][0] / 0x000B)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 5 (Unknow
    n: none ([12][0][0][0] / 0x000C)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 8 (Unknow
    n: none ([5][0][0][0] / 0x0005)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 9 (Unknow
    n: none ([11][0][0][0] / 0x000B)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 10 (Unkno
    wn: none ([12][0][0][0] / 0x000C)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 14 (Unkno
    wn: none ([5][0][0][0] / 0x0005)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 15 (Unkno
    wn: none ([11][0][0][0] / 0x000B)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 16 (Unkno
    wn: none ([12][0][0][0] / 0x000C)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 25 (Unkno
    wn: none ([5][0][0][0] / 0x0005)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 26 (Unkno
    wn: none ([11][0][0][0] / 0x000B)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 27 (Unkno
    wn: none ([12][0][0][0] / 0x000C)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 29 (Unkno
    wn: none ([5][0][0][0] / 0x0005)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 30 (Unkno
    wn: none ([11][0][0][0] / 0x000B)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 000000000494d6c0] Could not find codec parameters for stream 31 (Unkno
    wn: none ([12][0][0][0] / 0x000C)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    Input #0, mpegts, from 'udp://@239.255.255.7:1234':
      Duration: N/A, start: 64984.698511, bitrate: N/A
      Program 1569
        Metadata:
          service_name    : ONE
          service_provider: TEN Sydney
        Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:25[0x3e8]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:26[0x3f2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:27[0x3fc]: Unknown: none ([12][0][0][0] / 0x000C)
        Stream #0:23[0x202]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
    0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn,
    50 tbc
        Stream #0:24[0x2a0](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, ster
    eo, s16p, 192 kb/s
        Stream #0:7[0x241](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
      Program 1573
        Metadata:
          service_name    : TEN Digital
          service_provider: TEN Sydney
        Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:14[0x3ea]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:15[0x3f4]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:16[0x3fe]: Unknown: none ([12][0][0][0] / 0x000C)
        Stream #0:17[0x200]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
    0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn,
    50 tbc
        Stream #0:18[0x28a](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, ster
    eo, s16p, 256 kb/s
        Stream #0:19[0x240](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
      Program 1574
        Metadata:
          service_name    : TVSN
          service_provider: TEN Sydney
        Stream #0:6[0x206]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420
    p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 5
    0 tbc
        Stream #0:28[0x2b2](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, ster
    eo, s16p, 192 kb/s
        Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:29[0x3eb]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:30[0x3f5]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:31[0x3ff]: Unknown: none ([12][0][0][0] / 0x000C)
      Program 1575
        Metadata:
          service_name    : ONE
          service_provider: TEN Sydney
        Stream #0:23[0x202]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
    0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn,
    50 tbc
        Stream #0:24[0x2a0](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, ster
    eo, s16p, 192 kb/s
        Stream #0:7[0x241](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
        Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:25[0x3e8]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:26[0x3f2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:27[0x3fc]: Unknown: none ([12][0][0][0] / 0x000C)
      Program 1576
        Metadata:
          service_name    : ELEVEN
          service_provider: TEN Sydney
        Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:8[0x3e9]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:9[0x3f3]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:10[0x3fd]: Unknown: none ([12][0][0][0] / 0x000C)
        Stream #0:11[0x204]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
    0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn,
    50 tbc
        Stream #0:12[0x2a9](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, ster
    eo, s16p, 192 kb/s
        Stream #0:13[0x242](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
      Program 1577
        Metadata:
          service_name    : SpreeTV
          service_provider: TEN Sydney
        Stream #0:0[0x208]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420
    p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 5
    0 tbc
        Stream #0:1[0x2bc](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stere
    o, s16p, 192 kb/s
        Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:3[0x3ec]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:4[0x3f6]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:5[0x400]: Unknown: none ([12][0][0][0] / 0x000C)
      Program 1572
        Metadata:
          service_name    : TEN HD
          service_provider: TEN Sydney
        Stream #0:20[0x1ff]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv
    , bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
        Stream #0:21[0x289](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side
    ), fltp, 448 kb/s
        Stream #0:22[0x23f](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
        Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:14[0x3ea]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:15[0x3f4]: Unknown: none ([11][0][0][0] / 0x000B)
        Stream #0:16[0x3fe]: Unknown: none ([12][0][0][0] / 0x000C)
    [NULL @ 0000000005af6de0] Unable to find a suitable output format for 'pipe:'
    pipe:: Invalid argument
    

    The output of this command-line for channel 1317 (where it does not works) is the following :

    Microsoft Windows [Version 6.2.9200]
    (c) 2012 Microsoft Corporation. All rights reserved.
    C:\Users\Administrator.TMC>"C:\Program Files (x86)\Tv Tuner Mana
    ger\ServerModule\ffmpeg.exe" -i udp://@239.255.255.9:1234 -map 0:p:1317:0 -profi
    le:v baseline -crf 30 -preset ultrafast -vcodec libx264 -r 25 -vf scale=720:576
    -b:v 500k -f rtp udp://10.150.112.107:15048/ -map 0:p:1317:1 -acodec pcm_mulaw -
    strict experimental -ar 8k -ac 1 -b:a 128k -f rtp udp://10.150.112.107:15032/
    ffmpeg version N-71924-ga2190de Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
    enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
    ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
    le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
    able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
    ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
     --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
    e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
    ble-decklink --enable-zlib
      libavutil      54. 23.101 / 54. 23.101
      libavcodec     56. 37.100 / 56. 37.100
      libavformat    56. 31.102 / 56. 31.102
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5. 16.101 /  5. 16.101
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    [mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
    [NULL @ 0000000004789600] non-existing PPS 0 referenced
    [h264 @ 0000000004789600] decode_slice_header error
    [h264 @ 0000000004789600] no frame!
    [mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
    [NULL @ 000000000472a060] non-existing PPS 0 referenced
    [h264 @ 000000000472a060] decode_slice_header error
    [h264 @ 000000000472a060] no frame!
    [mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
    [h264 @ 000000000472a060] non-existing PPS 0 referenced
        Last message repeated 1 times
    [h264 @ 000000000472a060] decode_slice_header error
    [h264 @ 000000000472a060] no frame!
    [h264 @ 000000000472a060] non-existing PPS 0 referenced
        Last message repeated 1 times
    [h264 @ 000000000472a060] decode_slice_header error
    [h264 @ 000000000472a060] no frame!
    [mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
    [mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
        Last message repeated 1 times
    [mpeg2video @ 000000000472c620] Invalid frame dimensions 0x0.
    [h264 @ 0000000004789600] non-existing PPS 0 referenced
        Last message repeated 1 times
    [h264 @ 0000000004789600] decode_slice_header error
    [h264 @ 0000000004789600] no frame!
    [mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
    [mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
    [h264 @ 000000000472a060] non-existing PPS 0 referenced
        Last message repeated 1 times
    [h264 @ 000000000472a060] decode_slice_header error
    [h264 @ 000000000472a060] no frame!
    [mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
    [mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
        Last message repeated 1 times
    [mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
    [mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
        Last message repeated 1 times
    [mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
    [mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
        Last message repeated 1 times
    [mpeg2video @ 000000000472c620] Invalid frame dimensions 0x0.
    [mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
        Last message repeated 1 times
    [mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
    [mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
        Last message repeated 2 times
    [mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
    [mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
    [mpegts @ 0000000004710020] Could not find codec parameters for stream 3 (Unknow
    n: none ([5][0][0][0] / 0x0005)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [mpegts @ 0000000004710020] Could not find codec parameters for stream 4 (Unknow
    n: none ([11][0][0][0] / 0x000B)): unknown codec
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    Input #0, mpegts, from 'udp://@239.255.255.9:1234':
      Duration: N/A, start: 77183.898689, bitrate: N/A
      Program 1312
        Metadata:
          service_name    : 7 Sydney
          service_provider: Seven Network
        Stream #0:0[0x201]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420
    p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 14950 kb/s, 25 fps, 25 tbr, 90k tbn, 5
    0 tbc
        Stream #0:1[0x202](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stere
    o, s16p, 256 kb/s
        Stream #0:2[0x204](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
        Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
      Program 1313
        Metadata:
          service_name    : 7 Sydney
          service_provider: Seven Network
        Stream #0:0[0x201]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420
    p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 14950 kb/s, 25 fps, 25 tbr, 90k tbn, 5
    0 tbc
        Stream #0:1[0x202](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stere
    o, s16p, 256 kb/s
        Stream #0:2[0x204](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
        Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
      Program 1314
        Metadata:
          service_name    : 7TWO Sydney
          service_provider: Seven Network
        Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:18[0x221]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
    0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 14950 kb/s, 25 fps, 25 tbr, 90k tbn,
    50 tbc
        Stream #0:10[0x222](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, ster
    eo, s16p, 192 kb/s
        Stream #0:5[0x224](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
        Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
      Program 1315
        Metadata:
          service_name    : 7mate Sydney
          service_provider: Seven Network
        Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:13[0x231]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
    0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 14950 kb/s, 25 fps, 25 tbr, 90k tbn,
    50 tbc
        Stream #0:15[0x232](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, ster
    eo, s16p, 256 kb/s
        Stream #0:12[0x234](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
        Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
      Program 1316
        Metadata:
          service_name    : 7HD Sydney
          service_provider: Seven Network
        Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:6[0x241]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 19
    20x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
        Stream #0:16[0x243](eng): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, ster
    eo, fltp, 384 kb/s
        Stream #0:8[0x244](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
        Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
      Program 1317
        Metadata:
          service_name    : 7flix Sydney
          service_provider: Seven Network
        Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
        Stream #0:11[0x251]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
    0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 12500 kb/s, 25 fps, 25 tbr, 90k tbn,
    50 tbc
        Stream #0:9[0x253](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stere
    o, s16p, 128 kb/s
        Stream #0:14[0x254](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
        Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
      Program 1320
        Metadata:
          service_name    : RACING.COM
          service_provider: Seven Network
        Stream #0:7[0x281]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 64
    0x576 [SAR 8:5 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
        Stream #0:17[0x282](eng): Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011
    ), 48000 Hz, stereo, fltp
        Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
    Cannot map stream #0:3 - unsupported type.
    

    Thanks for your help

  • Decoder return of av_find_best_stream vs. avcodec_find_decoder

    7 octobre 2016, par Jason C

    The docs for libav's av_find_best_stream function (libav 11.7, Windows, i686, GPL) specify a parameter that can be used to receive a pointer to an appropriate AVCodec:

    decoder_ret - if non-NULL, returns the decoder for the selected stream

    There is also the avcodec_find_decoder function which can find an AVCodec given an ID.

    However, the official demuxing + decoding example uses av_find_best_stream to find a stream, but chooses to use avcodec_find_decoder to find the codec in lieu of av_find_best_stream's codec return parameter:

    ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
    ...
    stream_index = ret;
    st = fmt_ctx->streams[stream_index];
    ...
    /* find decoder for the stream */
    dec = avcodec_find_decoder(st->codecpar->codec_id);
    

    As opposed to something like:

    ret = av_find_best_stream(fmt_ctx, type, -1, -1, &dec, 0);
    

    My question is pretty straightforward: Is there a difference between using av_find_best_stream's return parameter vs. using avcodec_find_decoder to find the AVCodec?

    The reason I ask is because the example chose to use avcodec_find_decoder rather than the seemingly more convenient return parameter, and I can't tell if the example did that for a specific reason or not. The documentation itself is a little spotty and disjoint, so it's hard to tell if things like this are done for a specific important reason or not. I can't tell if the example is implying that it "should" be done that way, or if the example author did it for some more arbitrary personal reason.

  • avcodec_decode_video2 fails to decode after frame resolution change

    7 octobre 2016, par Krzysztof Kansy

    I'm using ffmpeg in Android project via JNI to decode real-time H264 video stream. On the Java side I'm only sending the the byte arrays into native module. Native code is running a loop and checking data buffers for new data to decode. Each data chunk is processed with:

    int bytesLeft = data->GetSize();
    int paserLength = 0;
    int decodeDataLength = 0;
    int gotPicture = 0;
    const uint8_t* buffer = data->GetData();
    while (bytesLeft > 0) {
        AVPacket packet;
        av_init_packet(&packet);
        paserLength = av_parser_parse2(_codecPaser, _codecCtx, &packet.data, &packet.size, buffer, bytesLeft, AV_NOPTS_VALUE, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
        bytesLeft -= paserLength;
        buffer += paserLength;
    
        if (packet.size > 0) {
            decodeDataLength = avcodec_decode_video2(_codecCtx, _frame, &gotPicture, &packet);
        }
        else {
            break;
        }
        av_free_packet(&packet);
    }
    
    if (gotPicture) {
    // pass the frame to rendering
    }
    

    The system works pretty well until incoming video's resolution changes. I need to handle transition between 4:3 and 16:9 aspect ratios. While having AVCodecContext configured as follows:

    _codecCtx->flags2|=CODEC_FLAG2_FAST;
    _codecCtx->thread_count = 2;
    _codecCtx->thread_type = FF_THREAD_FRAME;
    
    if(_codec->capabilities&CODEC_FLAG_LOW_DELAY){
        _codecCtx->flags|=CODEC_FLAG_LOW_DELAY;
    }
    

    I wasn't able to continue decoding new frames after video resolution change. The got_picture_ptr flag that avcodec_decode_video2 enables when whole frame is available was never true after that.
    This ticket made me wonder if the issue isn't connected with multithreading. Only useful thing I've noticed is that when I change thread_type to FF_THREAD_SLICE the decoder is not always blocked after resolution change, about half of my attempts were successfull. Switching to single-threaded processing is not possible, I need more computing power. Setting up the context to one thread does not solve the problem and makes the decoder not keeping up with processing incoming data.
    Everything work well after app restart.

    I can only think of one workoround (it doesn't really solve the problem): unloading and loading the whole library after stream resolution change (e.g as mentioned in here). I don't think it's good tho, it will propably introduce other bugs and take a lot of time (from user's viewpoint).

    Is it possible to fix this issue?

    EDIT:
    I've dumped the stream data that is passed to decoding pipeline. I've changed the resolution few times while stream was being captured. Playing it with ffplay showed that in moment when resolution changed and preview in application froze, ffplay managed to continue, but preview is glitchy for a second or so. You can see full ffplay log here. In this case video preview stopped when I changed resolution to 960x720 for the second time. (Reinit context to 960x720, pix_fmt: yuv420p in log).