VideoHelp Forum




+ Reply to Thread
Results 1 to 6 of 6
  1. Hello everybody

    I'm trying to re-encode an MPEG-2 file using this command (to keep all the original movie characteristics except for the video bitrate, that I want to decrease):

    ffmpeg -i input.mpg" -c copy -b:v 700k output.mpg
    but FFmpeg doesn't start the conversion and immediately stops with this error:

    av_interleaved_write_frame(): Invalid argument
    The complete log is here:

    ffmpeg -i "J:\input.mpg" -c copy -b:v 700k "J:\output.mpg"

    ffmpeg version N-44601-gcb3591e Copyright (c) 2000-2012 the FFmpeg developers
    built on Sep 19 2012 16:28:01 with gcc 4.7.1 (GCC)
    configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    libavutil 51. 73.101 / 51. 73.101
    libavcodec 54. 56.100 / 54. 56.100
    libavformat 54. 27.101 / 54. 27.101
    libavdevice 54. 2.100 / 54. 2.100
    libavfilter 3. 16.104 / 3. 16.104
    libswscale 2. 1.101 / 2. 1.101
    libswresample 0. 15.100 / 0. 15.100
    libpostproc 52. 0.100 / 52. 0.100
    [mpeg @ 003fbf00] max_analyze_duration 5000000 reached at 5016000
    Input #0, mpeg, from 'J:\input.mpg':
    Duration: 00:00:21.16, start: 0.097422, bitrate: 3954 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 3550 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
    Output #0, mpeg, to 'J:\output.mpg':
    Metadata:
    encoder : Lavf54.27.101
    Stream #0:0: Video: mpeg2video, yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 3550 kb/s, 25 fps, 90k tbn, 25 tbc
    Stream #0:1: Audio: mp2, 48000 Hz, stereo, 384 kb/s
    Stream mapping:
    Stream #0:0 -> #0:0 (copy)
    Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    [mpeg @ 03394440] pts (30104) < dts (36264) in stream 0
    av_interleaved_write_frame(): Invalid argument
    Here you find the input movie characteristics read by MediaInfo:

    General
    Complete name : J:\ALIDVR\2012-10-02.18.44.06-DEEJAY TV-443\000.MPG
    Format : MPEG-PS
    File size : 9.98 MiB
    Duration : 20s 870ms
    Overall bit rate : 4 010 Kbps

    Video
    ID : 224 (0xE0)
    Format : MPEG Video
    Format version : Version 2
    Format profile : Main@Main
    Format settings, BVOP : Yes
    Format settings, Matrix : Custom
    Format settings, GOP : M=3, N=12
    Duration : 20s 870ms
    Bit rate : 3 550 Kbps
    Width : 720 pixels
    Height : 576 pixels
    Display aspect ratio : 16:9
    Active Format Description : Letterbox 16:9 image
    Frame rate : 25.000 fps
    Standard : PAL
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Interlaced
    Scan order : Top Field First
    Compression mode : Lossy
    Bits/(Pixel*Frame) : 0.342
    Stream size : 8.83 MiB (88%)

    Audio
    ID : 192 (0xC0)
    Format : MPEG Audio
    Format version : Version 1
    Format profile : Layer 2
    Emphasis : 50/15ms
    Duration : 20s 625ms
    Bit rate mode : Constant
    Bit rate : 384 Kbps
    Channel(s) : 2 channels
    Sampling rate : 48.0 KHz
    Compression mode : Lossy
    Delay relative to video : -335ms
    Stream size : 967 KiB (9%)

    Menu

    Thank you very much for your help!
    Last edited by falco2000; 2nd Oct 2012 at 14:59.
    Falco2000, video newbie.
    Let's everyone help each other.
    Quote Quote  
  2. Member ozok's Avatar
    Join Date
    Oct 2011
    Location
    Turkey
    Search Comp PM
    AFAIK "-c:v copy" will just copy video stream, without a change. if you want to change bitrate, try changing

    ffmpeg -i input.mpg" -c copy -b:v 700k output.mpg
    to

    ffmpeg -i input.mpg" -vcodec mpeg2video -b:v 700k output.mpg
    also try using "-c:v" instead of "-c".
    Quote Quote  
  3. Thanks for your answer ozok.

    Originally Posted by ozok View Post
    AFAIK "-c:v copy" will just copy video stream, without a change.
    That's probably the right explanation and I was mistaking, but I've read on the FFmpeg documentation page this:

    For each stream, the last matching c option is applied, so

    ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT

    will copy all the streams except the second video, which will be encoded with libx264, and the 138th audio, which will be encoded with libvorbis.
    and I was mislead. The difference between the above two commands is infact the inclusion of the movie format (libx264) in the documentation example, while I only specified the bitrate.

    The error happens with this too:

    Originally Posted by ozok View Post
    also try using "-c:v" instead of "-c".
    Anyway, I still have the same problem: you say to use

    Originally Posted by ozok View Post
    ffmpeg -i input.mpg -vcodec mpeg2video -b:v 700k output.mpg
    and this creates a movie that has all characteristics of the input movie except for the video bitrate (and that's ok) but also produces these changes (seen with MediaInfo):

    OUTPUT MOVIE:

    Format settings, BVOP : Yes
    Format settings, Matrix : Custom
    Format settings, GOP : M=3, N=12
    Scan type : Interlaced
    Scan order : Top Field First
    while the original INPUT MOVIE is:

    Format settings, BVOP : No
    Format settings, Matrix : Default
    Format settings, GOP : M=1, N=12
    Scan type : Progressive
    I have the need to keep and match exactly (or al least the most of) the original movie characteristics. (That's why I tried the "-c copy -b:v 700k" command).

    How can I do?

    I searched in the FFmpeg documentation page and maybe:
    • the scan type and order could be kept with the setfield filter as explained in the FFmpeg documentation, although I still have to learn how to exactly use it
    • the GOP could be set with the -g option but in the documentation examples its argument is always only ONE, not two, as MediaInfo shows ("M=3, N=12"). How should I set "M" and "N" if I can specify one number only?
    • I didn't find any understandable hint for "Matrix". Is that the "colormatrix" cited in the documentation? Surely - I think - it's not the matrix of the unsharp filter or the matrix related to the audio encoding (also mentioned in the documentation page). So what are these "Matrix: default" and "Matrix: custom"?
    • I didn't find reference to "BVOP" in the main documentation page. Maybe is something that has to be set using a private option of the MPEG2VIDEO codec, as said in the documentation?
      Private options are listed under their corresponding containers/devices/codecs.
      If this is true, where could I see the MPEG2VIDEO codec "private options" to learn how to set the BVOP parameter?

    Thank you all for your precious help
    Last edited by falco2000; 3rd Oct 2012 at 16:02.
    Falco2000, video newbie.
    Let's everyone help each other.
    Quote Quote  
  4. Member ozok's Avatar
    Join Date
    Oct 2011
    Location
    Turkey
    Search Comp PM
    @falco2000 again i am not sure, but characteristics of input and output differ because of bitrate change. I am not sure but ffmpeg might be deciding proper settings for mpeg2 codec based on given bitrate because you did not specify them yourself manually. but that might be completely false so you must set a bitrate value close to input's and see what happens. also ffmpeg seems to be doing deinterlacing, so you might want to turn that off too.

    i do not have knowledge about mpeg2video specific options.
    Quote Quote  
  5. Originally Posted by ozok View Post
    @falco2000 again i am not sure, but characteristics of input and output differ because of bitrate change. [...] but that might be completely false so you must set a bitrate value close to input's and see what happens.
    I did several tests, also with a bitrate similar to the original, but the output movie is still not interlaced as the input.

    Originally Posted by ozok View Post
    so ffmpeg seems to be doing deinterlacing, so you might want to turn that off too.
    So I tried the ilme filter to keep/force the interlace format:

    ffmpeg -i input.mpg -c:v mpeg2video -b:v 15000k -flags:v ilme -c:a copy output.mpg
    and it partially works: MediaInfo shows that the output is now interlaced like the input file:

    Scan type : Interlaced
    Scan order : Top Field First
    but the other three characteristics (Matrix, GOP and BVOP) remain different from the input movie. And while the input movie is playable by the digital TV receiver that recorded it, the output one is still not playable (the receiver player shows a black screen if I play it).

    So I guess I should match the other characteristics (Matrix, GOP and BVOP) too. But how?
    Last edited by falco2000; 3rd Oct 2012 at 16:07.
    Falco2000, video newbie.
    Let's everyone help each other.
    Quote Quote  
  6. looking at the manual (http://ffmpeg.org/ffmpeg.html)
    gop size can be set with '-g X', where X is the size of the gop
    bvop specifies whether or not b-frames are used, the b-frame count can be set with '-bf X', where X is the number of consecutive b-frames, using -bf 0 should disable the use of b-frames
    not sure about the matrix but it might help to specify '-target type' (see manual for possible type values)
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!