Trim AVI video via FFMPEG results in black screen video, but audio is OK

1

1

I want to trim a AVI video (H264 codec) via ffmpeg. The time interval for the result is available as START_TIME_ORIG and DURATION_ORIG (both in microseconds). To make sure that the resulting video starts with an IDR frame, I determine START_TIME and DURATION via ffprobe by executing

ffprobe -show_frames -pretty -read_intervals [TIME_FROM%TIME_TO] input.avi

twice to get the IDR frames which are (1st call) closest to START_TIME_ORIG and (2nd call) closest to START_TIME_ORIG+DURATION_ORIG. TIME_FROM and TIME_TO is an interval of 5 seconds plus/minus around (1st call) START_TIME_ORIG and (2nd call) START_TIME_ORIG+DURATION_ORIG. To identify a frame as IDR frame I verify that key_frame=1 and pict_type=I. START_TIME is then set to pkt_dts_time of that frame. In a similar way I calculate DURATION.

Then ffmpeg is called:

ffmpeg -ss [START_TIME] -i input.avi -t [DURATION] -codec copy -reset_timestamps 1 -async 1 -map 0 -y output.avi

Unfortunately the resulting video has a black screen only, audio is OK. What is wrong with my approach? Thanks, mipi

BTW: That's the output of ffmpeg

    ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.1 (GCC) 20171128
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Invalid return value 0 for stream protocol
    Last message repeated 1 times
Input #0, avi, from '/home/mipi/Videos/OTR/Bruder_Schwarze_Macht_17.10.29_21-45_zdfneo_45_TVOON_DE.mpg.HQ.avi':
  Metadata:
    comment         : Auge um Auge Deutschland 2017|Die Deutsch-Türkin Sibel, 34, fühlt sich als Polizistin gut integriert. Ihr Bruder Melih, 21, empfindet anders: Sie seien nur die "ewigen Türken". Beide sind wie Feuer und Wasser.|Melih sucht seinen Platz. Mit Freund Tobi 
    title           : Bruder - Schwarze Macht
    encoder         : Lavf54.17.100
    encoded_by      : www.onlinetvrecorder.com
  Duration: 01:00:47.64, start: 0.000000, bitrate: 985 kb/s
    Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(tv, bt470bg, progressive), 720x576 [SAR 64:45 DAR 16:9], 780 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 192 kb/s
Output #0, avi, to '/home/mipi/Videos/OTR/Cut/Bruder_Schwarze_Macht_17.10.29_21-45_zdfneo_45_TVOON_DE.mpg.HQ.avi':
  Metadata:
    ICMT            : Auge um Auge Deutschland 2017|Die Deutsch-Türkin Sibel, 34, fühlt sich als Polizistin gut integriert. Ihr Bruder Melih, 21, empfindet anders: Sie seien nur die "ewigen Türken". Beide sind wie Feuer und Wasser.|Melih sucht seinen Platz. Mit Freund Tobi 
    INAM            : Bruder - Schwarze Macht
    ITCH            : www.onlinetvrecorder.com
    ISFT            : Lavf57.83.100
    Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(tv, bt470bg, progressive), 720x576 [SAR 64:45 DAR 16:9], q=2-31, 780 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[avi @ 0x5590b071a3c0] 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
frame=43401 fps=0.0 q=-1.0 size=  203531kB time=00:28:45.96 bitrate= 966.0kbits/frame=66964 fps=0.0 q=-1.0 Lsize=  303964kB time=00:44:28.48 bitrate= 933.1kbits/s speed=3.47e+03x    
video:236957kB audio:62779kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.410803%

mipi

Posted 2017-12-25T16:31:26.807

Reputation: 11

Play with ffplay and check. – Gyan – 2017-12-25T17:53:52.403

Solved: Resulting video can be run with VLC and ffplay. So, it seems to be a problem of the Gnome video player. @Mulvya: Thanks. – mipi – 2017-12-26T08:06:30.183

No answers