VideoHelp Forum




+ Reply to Thread
Page 5 of 7
FirstFirst ... 3 4 5 6 7 LastLast
Results 121 to 150 of 183
  1. Tried it both with and without, from memory. But not using quotes breaks it because of spaces in the filename anyway.
    Quote Quote  
  2. I need to see an example script where it doesn't work for you.
    Quote Quote  
  3. Code:
    for %%F in (*.mkv) do (
    ffmpeg -i "%%F" -vcodec copy -acodec copy -map a:0 "%~nF.ac3" -map v:0 "%~nF.mp4"
    )
    
    pause
    Fails for "%~nF".ac3 and %~nF.ac3 as well. Gives me an error about the substitution being invalid and immediately closes the command window. Had to double-click the batch and then quickly screenshot just to see the error.
    Last edited by koberulz; 10th Mar 2020 at 23:22. Reason: Typo
    Quote Quote  
  4. The percent sign in a batch file is used to indicate command line arguments passed to the batch file. To use it within a FOR loop you need to "escape" it.

    https://www.robvanderwoude.com/escapechars.php

    So you need to use %% instead of %. In this case: "%%~nF.ac3" and "%%~nF.mp4"
    Quote Quote  
  5. I went back to The West Wing, and if I run the AviSynth script to load it and apply TFM(pp=0), I get no combing at all during the show itself. But the opening credits seem to be interlaced.
    Quote Quote  
  6. Yes, it's very common for the opening and closing sequences for TV shows to be different than the body of the show. Individual shots are often sped up or slowed down to match the music. Titles are often overlaid as interlaced video (60 different fields per second) to smooth out their motion. Etc.
    Quote Quote  
  7. So how do I handle it within this process?
    Quote Quote  
  8. How do you want to handle it? I usually don't care about the credits and just use TFM() or TFM(pp=0).vinverse() to remove any residual comb artifacts -- especially if the credits don't move but only fade in/out. Or you could just encode the entire video at 59.94 fps to keep the fluid motion of the credits. Or encode VFR with the open and closing sequences at 59.94 fps and the body of the video at 23.976 fps.
    Quote Quote  
  9. https://youtu.be/JivPEYjYd20

    It's this sequence. Not exactly subtle.
    Quote Quote  
  10. Is flagging the whole thing as interlaced an option? Progressive footage seems to work just fine flagged as interlaced most of the time anyway, as most of these DVDs are progressive but interlaced-flagged.
    Quote Quote  
  11. Formerly 'vaporeon800' Brad's Avatar
    Join Date
    Apr 2001
    Location
    Vancouver, Canada
    Search PM
    Sometimes opening/closing credits are converted by another method while the rest of the episode is sped up, in order to keep the original pitch and and tempo of the music.
    Quote Quote  
  12. Originally Posted by koberulz View Post
    Is flagging the whole thing as interlaced an option? Progressive footage seems to work just fine flagged as interlaced most of the time anyway, as most of these DVDs are progressive but interlaced-flagged.
    Flagged? You mean encoded interlaced? You want to slow 25i video to 24i and encode interlaced? You could do that but it would be highly unusual. I wouldn't be surprised if many devices chocked on that.
    Quote Quote  
  13. Originally Posted by vaporeon800 View Post
    Sometimes opening/closing credits are converted by another method while the rest of the episode is sped up, in order to keep the original pitch and and tempo of the music.
    Hmm. Seems like that might be the case here, the original music matches pitch with that YouTube video better than the converted version does.

    Ugh.
    Quote Quote  
  14. Originally Posted by jagabo View Post
    There are tricky ways you can do that. For example, load two stereo audio tracks in AviSynth and combine them into a quad track with MergeChannels(). Then in ffmpeg separate the quad track back into two stereo tracks and encode them as separate audio streams.
    I have no idea how to load multiple audio tracks in AviSynth. In any event this won't work as the primary audio track is 5.1, only the secondary track is 2.0.
    Quote Quote  
  15. Originally Posted by koberulz View Post
    Originally Posted by jagabo View Post
    There are tricky ways you can do that. For example, load two stereo audio tracks in AviSynth and combine them into a quad track with MergeChannels(). Then in ffmpeg separate the quad track back into two stereo tracks and encode them as separate audio streams.
    I have no idea how to load multiple audio tracks in AviSynth.
    Simple:
    Code:
    Audio1 = LWlibavAudioSource("soundtrack1.ext")
    Audio2 = LWlibavAudioSource("soundtrack2.ext")
    MergedAudio = MixAudio(Audio1, Audio2)
    Originally Posted by koberulz View Post
    In any event this won't work as the primary audio track is 5.1, only the secondary track is 2.0.
    Sure it will work. You'll just have 8 audio channels (5+1+2) instead of four (2+2).
    Quote Quote  
  16. That requires each track to be its own file, no? My starting point is an MKV multiple tracks, not two separate audio files.
    Quote Quote  
  17. No, you are not limited to separate files. With LSmash and ffAudioSource you can specify which audio track is to be opened. Even if you were limited to separate files you could always demux one of the tracks to get a separate file.
    Quote Quote  
  18. Originally Posted by jagabo View Post
    Simple:
    Code:
    Audio1 = LWlibavAudioSource("soundtrack1.ext")
    Audio2 = LWlibavAudioSource("soundtrack2.ext")
    MergedAudio = MixAudio(Audio1, Audio2)
    Do you mean MergeChannels() instead of MixAudio()?

    And then how would I retrieve that for the ffmpeg step? I don't even know what to Google for in terms of doing that.
    Quote Quote  
  19. Yes, MergeChannels, not MixAudio. Use ffmpeg's "map" and "amerge" or "join" to select and merge audio channels to one stream.

    https://trac.ffmpeg.org/wiki/AudioChannelManipulation
    Quote Quote  
  20. How do I know what channel should go where though?

    EDIT: After more reading, even more confused. I'm not sure which filter I should be using, or how I should be using it, and I have no idea how to make it an audio track in the muxed file instead of just outputting an audio file which is what all those examples do.

    At present I'm guessing I have an AVS file that results in 7.1 audio where the first six channels are the 5.1 track and the last two are the stereo track.
    Last edited by koberulz; 15th Mar 2020 at 07:20.
    Quote Quote  
  21. Anyone? I cannot wrap my head around that ffmpeg documentation at all.
    Quote Quote  
  22. I was hoping you would figure something out on your own so I wouldn't have to spend my time on it. Here's what I came up with. Assuming input.avs merges a 5.1 track and a 2.0 track into a single 8 channel track (as discussed before):

    Code:
    ffmpeg -y -i "input.avs" -i input.avs ^
      -filter_complex "[0:a]channelmap=map=FL-FL|FR-FR|FC-FC|LFE-LFE|BL-BL|BR-BR:channel_layout=5.1" ^
      -filter_complex "[1:a]channelmap=map=SL-FL|SR-FR:channel_layout=stereo" ^
      -c:v libx264 ^
      -c:a ac3 ^
      -map 0:0 -map 0:1 -map 1:1 ^
      output.mkv
    There's probably a way to do it with a single input.avs but I don't feel like figuring it out. Note that ffmpeg assumes the 8 channel audio is 7.1 with the order: FL, FR, FC, LFE, BL, BR, SL SR.
    Quote Quote  
  23. Unfortunately no, it's too far outside what I'm familiar with for me to understand it enough to start working with it.

    Why are you using two input.avs? One for the first filter_complex and one for the second filter_complex? Is there a reason you can't run them both on the same input?

    From my reading of that: the first filter_complex maps the audio to track 0, the second maps the audio to track 1. We then encode the video as previously and re-encode the audio as ac3.

    But the map line throws me. 0:0 and 1:1 make sense, but why 0:1? The documentation doesn't seem to mention syntax for map so I'm not sure which is input and which is output, but that code seems to run the same track from the input into two different output tracks, which doesn't make much sense.

    Also, why the ^ symbols? Escaping the line breaks?
    Quote Quote  
  24. Originally Posted by koberulz View Post
    Why are you using two input.avs? One for the first filter_complex and one for the second filter_complex? Is there a reason you can't run them both on the same input?
    I couldn't figure out how to split one audio track into two, and then handle the two tracks differently. So to get two audio tracks I just loaded the AVS twice.

    Originally Posted by koberulz View Post
    From my reading of that: the first filter_complex maps the audio to track 0, the second maps the audio to track 1.
    The first filter_complex works on the audio track from file 0 (0:a). The second filter works on the audio track from file 1 (1:a).

    Originally Posted by koberulz View Post
    We then encode the video as previously and re-encode the audio as ac3.
    Yes. The video track from the second input file isn't used so it shouldn't slow down the processing.

    Originally Posted by koberulz View Post
    But the map line throws me. 0:0 and 1:1 make sense, but why 0:1?
    The first number is the input file number. file 0, file 1, etc. The second number is the track number within that file. So 0:1 is file 0, track 1. It could also have been written with the v/a convention "map 0:v map 0:a map 1:a".

    Originally Posted by koberulz View Post
    Also, why the ^ symbols? Escaping the line breaks?
    For the CLI end-of-line is normally the end of the command. So if you want to spread one long command line over several lines you need to escape the EOL. The command is equivalent to:

    Code:
    ffmpeg -y -i "input.avs" -i input.avs -filter_complex "[0:a]channelmap=map=FL-FL|FR-FR|FC-FC|LFE-LFE|BL-BL|BR-BR:channel_layout=5.1" -filter_complex "[1:a]channelmap=map=SL-FL|SR-FR:channel_layout=stereo" -c:v libx264 -c:a ac3 -map 0:0 -map 0:1 -map 1:1 output.mkv
    I though it was much easier to read and understand split over several lines where each line deals with one thing. It's common practice when programming to indent continued lines so it's obvious at a quick glance (the end of the line line may not be visible within the window and it can be a PITA to scroll horizontally over very long lines all the time).
    Quote Quote  
  25. I figured out how to do it with only one input. It turned out to be simpler than I expected:

    Code:
    ffmpeg -y -i "video.avs" ^
      -filter_complex "[0:1]channelmap=map=FL-FL|FR-FR|FC-FC|LFE-LFE|BL-BL|BR-BR:channel_layout=5.1" ^
      -filter_complex "[0:1]channelmap=map=SL-FL|SR-FR:channel_layout=stereo" ^
      -c:v libx264 ^
      -c:a ac3 ^
      output.mkv
    Quote Quote  
  26. I'm getting an error on MergeChannels saying the clips need to have the same sample rate, but MediaInfo reports they're both 48.0kHz.

    Code:
    Audio #1
    ID                                       : 2
    ID in the original source medium         : 189 (0xBD)-128 (0x80)
    Format                                   : AC-3
    Format/Info                              : Audio Coding 3
    Codec ID                                 : A_AC3
    Duration                                 : 1 h 35 min
    Bit rate                                 : 384 kb/s
    Channel(s)                               : 6 channels
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 31.250 FPS (1536 spf)
    Compression mode                         : Lossy
    Stream size                              : 263 MiB (6%)
    Title                                    : Dolby Digital 5.1
    Language                                 : English
    Default                                  : Yes
    Forced                                   : No
    
    Audio #2
    ID                                       : 3
    ID in the original source medium         : 189 (0xBD)-129 (0x81)
    Format                                   : AC-3
    Format/Info                              : Audio Coding 3
    Codec ID                                 : A_AC3
    Duration                                 : 1 h 35 min
    Bit rate                                 : 192 kb/s
    Channel(s)                               : 2 channels
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 31.250 FPS (1536 spf)
    Compression mode                         : Lossy
    Stream size                              : 132 MiB (3%)
    Title                                    : Commentary DD 2.0
    Language                                 : English
    Default                                  : No
    Forced                                   : No
    Code:
    for %%F in (*.mkv) do (
    echo A = LWLibAvVideoSource("%%F"^) > script.avs
    echo B = LWLibAvAudioSource("%%F",stream_index=1^) >> script.avs
    echo C = LWLibAVAudioSource("%%F",stream_index=2^) >> script.avs
    echo MergeChannels (A,B,C^) >> script.avs
    rem echo AudioDub(A,B^) >> script.avs
    echo AssumeFPS(24000,1001,sync_audio=true^) >> script.avs
    echo ResampleAudio(48000^) >> script.avs
    Quote Quote  
  27. A is not an audio channel.
    Quote Quote  
  28. What if I have two stereo tracks? I'm not sure how to know what ffmpeg expects the channels to be.
    Quote Quote  



Similar Threads

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