Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    602

    ffmpeg, mkv, and Jackie Chan...


    So I couldn't get a certain Jackie Chan movie anywhere. It's one of his older ones, really silly, but he makes me laugh. After months of checking the various libraries and rental shops, still nothing. Finally, out of desperation, I hit one of those shady file sharing websites.

    Score!

    5 part rar, just less than gig each. Sounds good. I'm a cheapo so I give them no money, so it takes 4 days to get all 5 chunks. Unwrap it and I have a 4914623383 byte mkv blob. It plays. Cool. Bad overdubs. Even better.

    Issue: the video stream has bad reference frames. It's basically unwatchable. Hey, scram it through ffmpeg and we're all good.

    MKV is a container format. Like a closet with fancy shelves and hangers. What you put in it is your choice. I think it uses it's own encoding tricks. I'm still learning.

    Inside this MKV is a video stream, and audio stream (en) and a bunch of subtitle streams. Nifty. I don't fuss with subtitles much, and at this point, it's not a priority.

    What I want is to fix the video stream:

    Code:
    ffmpeg -i IFILE.mkv -codec:a copy -q:v 2  OFILE.mpg
    No problem. Beautiful. But where did the audio go?

    I have tried innumerable variants on this command. I have fresh ffmpeg-2.4. A bit ornery to compile, but it seems to work great. It's a lot different from the 2008 model I've had around. The arguments are a lot like ImageMagick: nearly infinite, confusing, and poorly documented.

    Does anyone know where the audio went? Why does -q:v 2 work so well? I got it from one of my google searches.

  2. #2
    I'm not an expert, but async might be what you need for the audio:

    ffmpeg -i IFILE.mkv -codec:a copy -q:v 2 -async 1 OFILE.mpg

    although bad reference frames would get me looking at probesize:

    ffmpeg -probesize 10240 -i IFILE.mkv OFILE.mpg

    where 10240 is an ok place to start, but the number might have to be increased depending on how well it works. adding -async 1 before the output file name might be necessary, but I wouldn't expect it.

    hth

  3. #3
    Linux Enthusiast
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    602
    Thanks for the reply, but async and probesize make no difference. Bummer.

    What I'm getting on the write end is this:
    Code:
    Input file #0 (IFILE.mkv):
      Input stream #0:0 (video): 2744 packets read (37633785 bytes); 2743 frames decoded; 
      Input stream #0:1 (audio): 10715 packets read (12747596 bytes); 
      Input stream #0:2 (subtitle): 0 packets read (0 bytes); 
      Input stream #0:3 (subtitle): 0 packets read (0 bytes); 
      Input stream #0:4 (subtitle): 0 packets read (0 bytes); 
      Input stream #0:5 (subtitle): 1 packets read (340 bytes); 
      Input stream #0:6 (subtitle): 0 packets read (0 bytes); 
      Total: 13460 packets (50381721 bytes) demuxed
    Output file #0 (OFILE.mpg):
      Output stream #0:0 (video): 2742 frames encoded; 2742 packets muxed (67010489 bytes); 
      Output stream #0:1 (audio): 10715 packets muxed (12747596 bytes); 
      Total: 13457 packets (79758085 bytes) muxed
    2745 frames successfully decoded, 0 decoding errors
    For a partial write, enough to see if it's working or not.
    On the read end (OFILE.mpg) I get this:
    Code:
    MPEG: No audio stream found -> no sound.
    VIDEO:  MPEG1  1280x546  (aspect 1)  24.000 fps    0.0 kbps ( 0.0 kbyte/s)
    ID_FILENAME=OFILE.mpg
    ID_DEMUXER=mpegps
    ID_VIDEO_FORMAT=0x10000001
    ID_VIDEO_BITRATE=0
    ID_VIDEO_WIDTH=1280
    ID_VIDEO_HEIGHT=546
    ID_VIDEO_FPS=24.000
    ID_VIDEO_ASPECT=0.0000
    ID_LENGTH=0.00
    ==========================================================================
    Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough
    VDec: vo config request - 1280 x 546 (preferred colorspace: Mpeg PES)
    VDec: using Mpeg PES as output csp (no 0)
    Movie-Aspect is undefined - no prescaling applied.
    VO: [null] 1280x546 => 1280x546 Mpeg PES  [fs] [zoom]
    Selected video codec: [mpegpes] vfm: mpegpes (MPEG-PES output (.mpg or DXR3/IVTV/DVB/V4L2 card))
    ==========================================================================
    ID_VIDEO_CODEC=mpegpes
    Audio: no sound
    It looks like it's writing the audio, but it isn't.

    Something I might try here soon if I cannot figure it out, is to demux the entire thing into separate video and audio files. Scram the video file through a filter process, then remux them back together.

    I was hoping to get it all in one command, but that'll probably work.

  4. $spacer_open
    $spacer_close
  5. #4
    Just posting my notes, Works for me, YMMV depending on what you are running.

    avconv -i input.mkv -vcodec copy -acodec copy output.mp4
    or
    ffmpeg -i input.mkv -vcodec copy -acodec copy output.mp4

    Works for .avi on the end also

    which can be run on multiple files via a simple Bash Shell Script:

    #!/bin/bash
    #avconv --help
    IFS=$'\n'
    clear
    for filename in *.mkv
    do
    echo "$filename"
    newfilename="${filename%.mkv}.mp4"
    echo "${newfilename}"
    avconv -i $filename -vcodec copy -acodec copy $newfilename
    done
    I refuse to let fear and fear of others rule my life. It puts my humanity at risk.
    Accepting Death is the only way to stay alive.

  6. #5
    Linux Enthusiast
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    602
    -->
    Duh.

    So I decided to rip it into separate streams. I dumped the audio to wav (1186428972 bytes) with this command:
    Code:
    mplayer "IFILE.mkv" -vc null -vo null -ao pcm:fast:file="OFILE.wav"
    and the video to mpg with this command:
    Code:
    ffmpeg -i IFILE.mkv -q:v 2 OFILE.mpg
    and didn't even bother with the audio track. Then I wait a bit until I have a chunk and play it. What the heck! It has audio now *and* the video is fixed. I guess I thought the command was going to be a lot more complicated than it needs to be, fussing about with bitrates and stuff.

    It just shows to go ya, try the simple things **first**.

    I'll mark as solved. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •