1

I have a set of FLV files which I want to play with GStreamer. All files have incorrect header/metadata, like this one:

https://drive.google.com/file/d/1FcKbYd2-D7ZiIG5VpRxpbqshCixp8iaR/view?usp=sharing

Both VLC and ffplay are able to play this file using their special magic. Although, Mediainfo shows truncated video info for the file:

Video
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Codec ID                                 : 7
Duration                                 : 12 s 633 ms
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Bit depth                                : 8 bits

For correct files there are at least the format profile and level.

gst-discoverer-1.0 doesn't want to detect the video stream at all:

Properties:
  Duration: 0:00:00.116000000
  Seekable: yes
  Live: no
  container: Flash
    audio: MPEG-4 AAC
      Stream ID: a72c1038e0bf52d7668cb945588d7bca2547bd58212aa7f08db439aeadfcbd95/audio
      Language: <unknown>
      Channels: 2 (front-left, front-right)
      Sample rate: 48000
      Depth: 32
      Bitrate: 0
      Max bitrate: 0
    video: H.264
      Stream ID: (NULL)
      Width: 0
      Height: 0
      Depth: 0
      Frame rate: 0/1
      Pixel aspect ratio: 1/1
      Interlaced: false
      Bitrate: 0
      Max bitrate: 0

gst-play-1.0 launches, but shows errors and doesn't show the preview:

gst-play-1.0.exe "C:\Users\me\Downloads\custom.flv"
Press 'k' to see a list of keyboard shortcuts.
Now playing C:\Users\me\Downloads\custom.flv
WARNING No decoder available for type 'video/x-h264, stream-format=(string)avc, codec_data=(buffer)000000016742c020da014016ec0440000003004000001e03c60ca80000000168ce3c80'.
WARNING debug information: ../gst/playback/gsturidecodebin.c(960): unknown_type_cb (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0
Redistribute latency...
0:00:12.6 / 0:00:12.6
Reached end of play list.

I'm looking for any way to either make GStreamer play such files correctly (maybe there is some plugin that allows to do so?) or to fix the video header.

Anton Serov
  • 174
  • 2
  • 12

2 Answers2

1

Remux your video file with FFMPEG:

ffmpeg -i custom.flv -c:v copy -c:a copy fixed.flv
Florian Zwoch
  • 6,764
  • 2
  • 12
  • 21
  • Yes, remuxing works, thank you. But I want to know more about the internals behind what FFmpeg performs there. I mean what information is incorrect in the headers and how to fix them – Anton Serov Oct 29 '21 at 10:15
  • Well you asked for a way to fix it so it plays in GStreamer. You need to examine the bitstream and compare it to the specification if you want to know whats wrong with it. – Florian Zwoch Oct 29 '21 at 11:58
  • 1
    _`"...What information is incorrect in the headers and how to fix them?"`_ @AntonSerov I'll check your FLV later on but usually FFmpeg generates a new header based on the audio/video codec's own settings. For example, if the FLV header says `width = 0` it's still possible to get the width & height from the H264 video bytes' **PPS** (Picture Parameter Setiings) header. – VC.One Nov 01 '21 at 14:30
  • Thank you @VC.One! The problem was mainly in the header. To generate the header I used the extra data returned by FFmpeg encoder. But the header is not just extra data, it should be generated as AVCDecoderConfigurationRecord following ISO/IEC-14496-15 – Anton Serov Nov 07 '21 at 13:40
1

The problem was in the video header. To generate the header I was using the extra data returned by FFmpeg encoder. But the header is not just the extra data, it should rather be generated as AVCDecoderConfigurationRecord structure following ISO/IEC-14496-15 standard.

Anton Serov
  • 174
  • 2
  • 12